type mas=array[1..27]of integer;
var s1,s2:string;
    n1,n2:mas;
    i:integer;
procedure sort(var a:mas; l,r:integer);
var i,j:integer;
    t,b:integer;
begin
 i:=l; j:=r;
 b:=a[(i+j)div 2];
 repeat
  while a[i]>b do inc(i);
  while a[j]<b do dec(j);
  if i<=j then begin
   t:=a[i]; a[i]:=a[j]; a[j]:=t;
   inc(i); dec(j);
  end;
 until(i>j);
 if i<r then sort(a,i,r);
 if l<j then sort(a,l,j);
end;

begin
 assign(input,'ancient.in'); reset(input);
 assign(output,'ancient.out'); rewrite(output);
 readln(s1);
 readln(s2);
 fillchar(n1,sizeof(n1),0);
 fillchar(n2,sizeof(n2),0);
 for i:=1 to length(s1)do inc(n1[ord(s1[i])-ord('A')+1]);
 for i:=1 to length(s2)do inc(n2[ord(s2[i])-ord('A')+1]);
 sort(n1,1,26);
 sort(n2,1,26);
 i:=1;
 while (i<=26)and(n1[i]=n2[i]) do inc(i);
 if i<>27 then writeln('NO')
 else writeln('YES');
 close(output);
 close(input);
end.