program AA;

{$APPTYPE CONSOLE}

uses
  SysUtils;
  label mmm;
  var f:text;
    f1:text;
    alef:array[1..26] of byte;{; chislo vhojdeniy;}
    alef1:array[1..26] of byte;{ chislo vhojdeniy;}
    s1,s2:string;
    k,n,n1,i:byte;

begin
  assignfile(f,'ancient.in');
  assignfile (f1,'ancient.out');
  reset(f);
  rewrite(f1);
  readln(f,s1);
  readln(f,s2);
  n := length(s1);
n1:=length(s2);
if n<>n1 then begin
   write(f1,'NO');
   goto mmm;
   end;
 for i := 1 to n do begin
   for n1:= 1 to n do begin
     if s1[i] = s1[n1] then alef[i]:= alef[i]+1;
     if s2[i] = s2[n1] then alef1[i]:=alef1[i]+1;
     end;
  end;
 for i := 1 to n-1  do
   for n1 := i+1 to n do begin
   if alef[i] > alef[n1] then
      begin
      k:=alef[i];
      alef[i]:=alef[n1];
      alef[n1]:=k;
      end;
   if alef1[i] > alef1[n1] then
      begin
      k:=alef1[i];
      alef1[i]:=alef1[n1];
      alef1[n1]:=k;
      end;
   end;{for}
 for i := 1 to n do
 if alef[i]<> alef1[i] then begin
  write(f1,'NO');
  goto mmm;
  end;
write (f1,'YES');

  { TODO -oUser -cConsole Main : Insert code here }

  mmm:
  closefile(f1);
  CLOSEFILE(F);
  end.
