program ancient;

{$APPTYPE CONSOLE}

uses
  SysUtils;
  var
  fin,fout:textfile;
s1,s2:string;
i,j,tmp:integer;
a1,a2,b1,b2:array [1..26] of integer;
max,k,buf:integer;
err:boolean;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  assign (fin,'ancient.in');
  assign(fout,'ancient.out');
  reset(fin);
  readln(fin,s1);
  readln(fin,s2);
  close(fin);
  for i:=1 to length(s1) do
  begin
     a1[ord(s1[i])-64]:=a1[ord(s1[i])-64]+1;
     a2[ord(s2[i])-64]:=a2[ord(s2[i])-64]+1;
  end;
  repeat
   err:=false;
   for i:=1 to 26 do
   for j:=i+1 to 26 do
     if a1[i]<a1[j] then begin
     tmp:=a1[i];
     a1[i]:=a1[j];
     a1[j]:=tmp;
     err:=true;
     end;
   until err=false;
  repeat
   err:=false;
   for i:=1 to 26 do
   for j:=i+1 to 26 do
     if a2[i]<a2[j] then begin
     tmp:=a2[i];
     a2[i]:=a2[j];
     a2[j]:=tmp;
     err:=true;
     end;
   until err=false;
err:=false;
   for i:=1 to 26 do
   begin
    if a1[i]<>a2[i] then begin err:=true; break;
    end;
   end;
 rewrite(fout);
 if err= true then writeln(fout,'NO') else writeln(fout,'YES');
close(fout);
 
end.
