{$APPTYPE CONSOLE}
var
  s:string;
  seta,setb,a,b:array[0..255]of longint;
  i:longint;

begin
  assign(input,'ancient.in'); reset(input);
  assign(output,'ancient.out'); rewrite(output);
  readln(s);
  for i:=1 to length(s) do inc(a[ord(s[i])]);
  readln(s);
  for i:=1 to length(s) do inc(b[ord(s[i])]);
  for i:=0 to 255 do inc(seta[a[i]]);
  for i:=0 to 255 do inc(setb[b[i]]);
  for i:=1 to 255 do if seta[i]<>setb[i] then begin
    write('NO');
    exit;
  end;
  write('YES');
end.
 