program Project2;

{$APPTYPE CONSOLE}

Var
        S1, S2 : AnsiString;
        Kol1, kol2 : Array['A'..'Z'] Of LongInt;
        Kol3, Kol4 : Array[0..101] Of LongInt;
        c : Char;
        i : LongInt;
        Fl : Boolean;
begin
  Assign(Output, 'ancient.out');
  Rewrite(Output);
  Assign(Input, 'ancient.in');
  Reset(input);
  ReadLn(S1);
  ReadLn(S2);
  For i:= 1 To Length(S1) Do
        Inc(Kol1[S1[i]]);
  For i:= 1 To Length(S2) Do
        Inc(Kol2[S2[i]]);
  For c:= 'A' To 'Z' Do
   Inc(Kol3[Kol1[c]]);
  For c:= 'A' To 'Z' Do
   Inc(Kol4[Kol2[c]]);
   Fl:= True;
  For i:= 1 To 100 Do
   If Kol3[i] <> Kol4[i] Then
        Fl:= False;
   If Fl Then
        Writeln('YES') Else
        Writeln('NO');
  Close(Input);
  Close(Output);
end.
