program ancient1;
{$APPTYPE CONSOLE}
type
  aaaa=string[101];
var
 i:integer;
 st1,st2: aaaa;
 s1,s2: array['A'..'Z']of integer;
 t1,t2: char;
 tmp: integer;
 yes: boolean;
 
begin
 assign(input,'ancient.in');reset(input);
 assign(output,'ancient.out');rewrite(output);
 readln(st1);
 readln(st2);

 fillchar(s1,sizeof(s1),0);
 fillchar(s2,sizeof(s2),0);
 for i:=1 to length(st1) do inc(s1[st1[i]]);
 for i:=1 to length(st2) do inc(s2[st2[i]]);

 for t1:='A' to 'Y' do
 for t2:=chr(ord(t1)+1) to 'Z' do
 if s1[t1]>s1[t2] then
 begin
   tmp:=s1[t1];
   s1[t1]:=s1[t2];
   s1[t2]:=tmp;
 end;

 for t1:='A' to 'Y' do
 for t2:=chr(ord(t1)+1) to 'Z' do
 if s2[t1]>s2[t2] then
 begin
   tmp:=s2[t1];
   s2[t1]:=s2[t2];
   s2[t2]:=tmp;
 end;

 yes:=true;
 for t1:='A' to 'Z' do
 if (s1[t1]<>s2[t1]) then
 begin
   yes:=false;
   break;
 end;

 if yes then writeln('YES') else writeln('NO');
 
 close(input);
 close(output);
end.

