program pa;

const infile  = 'ancient.in';
      outfile = 'ancient.out';

var s1, s2 : string;
    a1, a2 : array[0..25]of byte;

procedure init;
 begin
  assign(input, infile); reset(input);
  assign(output, outfile); rewrite(output);
  readln(s1); fillchar(a1, sizeof(a1), 0);
  readln(s2); fillchar(a2, sizeof(a2), 0);
 end;

procedure solve;
var i, j, t : longint;
 begin
  for i := 1 to length(s1) do inc(a1[ord(s1[i]) - ord('A')]);
  for i := 1 to length(s2) do inc(a2[ord(s2[i]) - ord('A')]);
  for i := 0 to 24 do
   for j := i + 1 to 25 do begin
     if a1[i] > a1[j] then begin t := a1[i]; a1[i] := a1[j]; a1[j] := t; end;
     if a2[i] > a2[j] then begin t := a2[i]; a2[i] := a2[j]; a2[j] := t; end;
    end;
  for i := 0 to 25 do
   if a1[i] <> a2[i] then begin
     writeln('NO');
     close(output);
     halt(0);
    end;
 end;

procedure save;
 begin
  writeln('YES');
  close(output);
 end;

begin
 init;
 solve;
 save;
end.