const
 fin='ancient.in';
 fout='ancient.out';

var
 S1, S2 : string;
 C1,C2:array['A'..'Z'] of LongInt;
 K1,K2:array[0..256] of LongInt;

 I:LongInt;

 C:char;

 Ok:boolean;

begin
 assign(Input,fin); reset(input);
 assign(Output,fout); rewrite(output);
 readln(S1); Readln(S2);
 For I:=1 to length(S1) do inc(C1[S1[I]]);
 For I:=1 to length(S2) do inc(C2[S2[I]]);
 For C:='A' to 'Z' do Inc(K1[C1[C]]);
 For C:='A' to 'Z' do Inc(K2[C2[C]]);

 Ok:=true;

 For I:=0 to 256 do
   if K1[I]<>K2[I] then Ok:=False;

 if (Ok) then WriteLn('YES') else WriteLn('N0');

 close(input); close(output);
end.