Var a,b:array['A'..'Z']of integer;
    a1,b1:array[1..26]of integer;
    s1,s2:string;
    ans:integer;

Procedure swap(var qw,er:integer);
Var ty:integer;
Begin
ty:=qw; qw:=er; er:=ty;
End;


Procedure Init;
var i:char;
Begin
readLN(s1);
readLN(s2);
For i:='A' to 'Z' do Begin
 a[i]:=0; b[i]:=0;
End;
End;

Procedure Solve;
 Var i,q,w:integer;
      j:char;
      f:boolean;
Begin
If length(s1)=length(s2) then Begin
For i:=1 to length(s1) do Begin
 Inc(a[s1[i]]);
End;
For i:=1 to length(s2) do Begin
 Inc(b[s2[i]]);
End;
fOR I:=1 TO 26 DO Begin A1[i]:=0; b1[i]:=0; end;
For j:='A' to 'Z' do a1[ord(j)-ord('A')+1]:=a[j];
For j:='A' to 'Z' do b1[ord(j)-ord('A')+1]:=b[j];

For q:=1 to 25 do
  For w:=q+1 to 26 do Begin
    If a1[q]>a1[w] then swap(a1[q],a1[w]);
    If b1[q]>b1[w] then swap(b1[q],b1[w]);
  End;
f:=true;
For i:=1 to 26 do if a1[i]<>b1[i] then f:=false;
If f=true then ans:=1 else ans:=0;

End else Begin
 ans:=0;
End;
End;

Procedure Save;
Begin
iF ANS = 1 then write('YES') else write('NO');
End;

begin
assign(input,'ancient.in'); reset(input);
assign(output,'ancient.out'); rewrite(output);
  Init;
  Solve;
  Save;
close(input);
close(output);
end.
