program Project1;

type
  IntArray = array ['A'..'Z'] of Integer;
  PocketArray = array [0..100] of Integer;

var
  s1, s2, s0 : string;
  c1, c2 : IntArray;
  p1, p2 : PocketArray;

function GetResult : string;
var
  i, j : Integer;
  ch : Char;
begin
  for ch := 'A' to 'Z' do
  begin
    Inc(p1[c1[ch]]);
    Inc(p2[c2[ch]]);
  end;

  for i := 0 to 100 do
    for j := 0 to 100 do
      if p1[i] <> p2[i] then
      begin
        Result := 'NO';
        Exit;
      end;
  Result := 'YES';
end;

var
  i : Integer;
begin
  AssignFile(Input, 'ancient.in');
  Reset(Input);
  Readln(s1);
  Readln(s2);
  CloseFile(Input);

  for i := 1 to Length(s1) do
  begin
    Inc(c1[s1[i]]);
    Inc(c2[s2[i]]);
  end;

  AssignFile(Output, 'ancient.out');
  Rewrite(Output);
  Writeln(GetResult);
  CloseFile(Output);
end.
