program taskA;
{$APPTYPE CONSOLE}
const
   MAX = 26;
var
   fi,fo:TextFile;
   Cnt1,Cnt2: array [1..MAX] of longint;
   i1,i2,b1: longint;
   S1,S2: String;
   IsOK: boolean;

begin
  AssignFile(fi,'ancient.in');
  AssignFile(fo,'ancient.out');
  Rewrite(fo);
  Reset(fi);
   //init
   FillChar(Cnt1,SizeOf(Cnt1),0);
   FillChar(Cnt2,SizeOf(Cnt2),0);
   //input
   Readln(fi,S1);
   Readln(fi,S2);
   //solve
   //count
   for i1:=1 to length(S1) do inc(Cnt1[ord(S1[i1])-ord('A')+1]);
   for i1:=1 to length(S2) do inc(Cnt2[ord(S2[i1])-ord('A')+1]);
   //sort
   for i1:=1 to MAX-1 do
      for i2:=i1+1 to MAX do if Cnt1[i1]<Cnt1[i2] then
         begin b1:=Cnt1[i1]; Cnt1[i1]:=Cnt1[i2]; Cnt1[i2]:=b1; end;
   for i1:=1 to MAX-1 do
      for i2:=i1+1 to MAX do if Cnt2[i1]<Cnt2[i2] then
         begin b1:=Cnt2[i1]; Cnt2[i1]:=Cnt2[i2]; Cnt2[i2]:=b1; end;
   //compare
   IsOK:=true;
   for i1:=1 to MAX do if Cnt1[i1]<>Cnt2[i1] then
      begin
         IsOK:=false;
         break;
      end;
   //output
   if IsOK then Writeln(fo,'YES')
           else Writeln(fo,'NO');

  Close(fo);
  Close(fi);
end.
