
var
 k,l,kl,k1,k2,i,j,len1,len2,j1,j2: Integer;
 s1,s2, st1, st2, ch: string;
 bl: boolean;
 d1,d2: array [1..256] of integer;
begin
assign(input,'ancient.in'); reset(input);
assign(output,'ancient.out'); rewrite(output);
readln(s1);
readln(s2);
bl:=true;
Len1:=Length(s1);
Len2:=Length(s2);
St1:=s1;
St2:=s2;
j1:=0;
i:=1;
while i<=Len1 do
 begin
 j1:=j1+1;
 ch[j1]:=s1[i];
 d1[j1]:=1;
 k1:=i+1;
  while k1<=Len1 do
   begin
   if ch[j1] = s1[k1] then
    begin
    d1[j1]:=d1[j1]+1;
    Delete(s1,k1,1);
    Len1:=Len1-1;
    end
   else k1:=k1+1;
   end;

  i:=i+1;
 end;
{____________________________}
j2:=0;
i:=1;ch:='';
while i<=Len2 do
 begin
  j2:=j2+1;
 ch[j2]:=s2[i];
 d2[j2]:=1;
 k2:=i+1;
  while k2<=Len2 do
   begin
    if ch[j2] = s2[k2] then
    begin
    d2[j2]:=d2[j2]+1;
    Delete(s2,k2,1);
    Len2:=Len2-1;
    end
   else k2:=k2+1;
   end;

  i:=i+1;
 end;
{ _____________________________-------- }
if j1=j2 then
begin
  for k:=1 to j1 do
  for l:=K to j1 do
   begin
   if d1[k]>d1[l] then
    begin
    kl:=d1[k];
    d1[k]:=d1[l];
    d1[l]:=kl;
    end;
   if d2[k]>d2[l] then
    begin
    kl:=d2[k];
    d2[k]:=d2[l];
    d2[l]:=kl;
    end;
   end;
 for k:=1 to j1 do if d1[k]<>d2[k] then bl:=false;
 if bl then write('YES') else write('NO');
 end   ELSE   WRITE('NO');


end.