{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MAXSTACKSIZE $3C00000}
{$APPTYPE CONSOLE}
type
 int = integer;
 real = extended;

var
  k1,k2: array[0..1000] of int;
  s1,s2: string;
  n,i,j,t: int;

begin
assign(input,'ancient.in');reset(input);
assign(Output,'ancient.out');rewrite(output);
FillChar(k1,sizeof(k1),0);
FillChar(k2,sizeof(k2),0);
Readln(s1);
Readln(s2);

For i := 1 to length(s1) do inc(k1[ord(s1[i])]);
For i := 1 to length(s1) do inc(k2[ord(s2[i])]);
n := 255;
For i := 0 to n-1 do
  For j := i+1 to n do
    If k1[i] > k1[j] THen
      begin
        t := k1[i];
        k1[i] := k1[j];
        k1[j] := t;
      end;

For i := 0 to n-1 do
  For j := i+1 to n do
    If k2[i] > k2[j] THen
      begin
        t := k2[i];
        k2[i] := k2[j];
        k2[j] := t;
      end;

For i := 0 to n do
  If k1[i] <> k2[i] Then
    begin
      Writeln('NO');
      Halt;
    end;
Writeln('YES');
end.