Type    Mas=Array[0..27] of LongInt;
var     i,j,k,l,m,n                     : LongInt;
        A,B                             : Mas;
        S1,S2                           : String;

PROCEDURE NO;
Begin
 writeln('NO');
 close(output);
 halt(0);
End;

procedure swap(var a,b: LongInt);
var t: LongInt;
Begin
 t:=a;
 a:=b;
 b:=t;
End;

BEGIN
 Assign(Input,'ancient.in');
 Assign(Output,'ancient.out');
 Rewrite(Output);
 Reset(INput);
  ReadLn(S1); n:=length(s1);
  ReadLn(s2); m:=length(s2);
  if n<>m then NO;
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  For i:=1 to N do
   inc(a[  Ord(S1[i])-Ord('A')+1 ]);
  For i:=1 to N do
   inc(b[  Ord(S2[i])-Ord('A')+1 ]);

  For i:=1 to 26-1 do
   For j:=i+1 to 26 do
    If a[i]<a[j] then
     swap(a[i],a[j]);

  For i:=1 to 26-1 do
   For j:=i+1 to 26 do
    If b[i]<b[j] then
     swap(b[i],b[j]);

  For i:=1 to 26 do
   if a[i]<>b[i] then NO;

 writeln('YES');
 Close(Input);
 Close(OUtput);
END.