program ancient;

{$APPTYPE CONSOLE}
type
 mas=array[1..26] of integer;
var
 m1,m2: mas;
 f:text;
 s1,s2:string;
 a1,a2:array['A'..'Z']of integer;
 i,l,n:integer;
 c:char;
 flag:boolean;
procedure sort(var a:mas);
var
 tmp,ind,i,j:integer;
 b:boolean;
begin
  for i:=1 to n do
  begin
    ind:=i;
    b:=false;
    for j:=i to n do
      if (a[ind]<a[j]) then
      begin
        ind:=j;
        b:=true;
      end;
    if b then
    begin
      tmp:=a[i];
      a[i]:=a[ind];
      a[ind]:=tmp;
    end;
  end;
end;
begin
 assign(f,'ancient.in');
 reset(f);
 s1:='';
 s2:='';
 readln(f,s1);
 readln(f,s2);
 l:=length(s1);
 n:=0;
 for c:='A' to 'Z' do
 begin
  a1[c]:=0;
  a2[c]:=0;
 end;
 for i:=1 to l do
 begin
  inc(a1[s1[i]]);
 end;
 for i:=1 to l do
 begin
  inc(a2[s2[i]]);
 end;
 i:=1;
 for c:='A' to 'Z' do
 begin
  m1[i]:=a1[c];
  m2[i]:=a2[c];
  inc(i);
 end;
 n:=26;
 sort(m1);
 sort(m2);
 flag:=true;
 for i:=1 to 26 do
  if (m1[i]<>m2[i]) then
  begin
   flag:=false;
   break;
  end;
 close(f);
 assign(f,'ancient.out');
 rewrite(f);
 if flag then write(f,'YES')
 else write(f,'NO');
 close(f);
end.
