program pa;
{$APPTYPE CONSOLE}


const
 Filec='ancient';
 Filei=Filec+'.in';
 Fileo=Filec+'.out';
var
 a,b: array[ord('A')..ord('Z')] of Integer;
 sa,sb: string;
 i,j,tmp: Integer;
 Res,sorted: Boolean;
begin
 Assign(input,Filei); Reset(input);
 Assign(output,Fileo);Rewrite(output);
 ReadLN(sa);ReadLN(sb);
 if Length(sa)=Length(sb) then begin
   for i:=1 to length(sa) do begin
        inc(a[ord(sa[i])]);
        inc(b[ord(sb[i])]);
   end;
   sorted := false;
   while not sorted do
     begin
       sorted := true;
       for i := ord('A') to ord('Z')-1 do
         begin
           if a[i] > a[i+1] then
             begin
               sorted := false;
               tmp := a[i];
               a[i] := a[i+1];
               a[i+1] := tmp;
             end;
         end;
       end;


   sorted := false;
   while not sorted do
     begin
       sorted := true;
       for i := ord('A') to ord('Z')-1 do
         begin
           if b[i] > b[i+1] then
             begin
               sorted := false;
               tmp := b[i];
               b[i] := b[i+1];
               b[i+1] := tmp;
             end;
         end;
       end;



   Res:=True;
   for i:=ord('A') to ord('Z') do begin
        Res:=a[i]=b[i];
        if not Res then break;
   end;
   if Res then WriteLN('YES') else WriteLN('NO');
 end else begin
   WriteLN('NO');
 end;
 Close(input);Close(output);
end.
 