program Aa;

{$APPTYPE CONSOLE}

uses
  SysUtils;
  var
  f1,f2:text;
  s1,s2,s3:string;
  l1,l2,i,k,j,p,e:integer;
  a,b:array[1..100] of integer;
  begin
 assign(f1,'ancient.in');reset(f1);
 readln(f1,s1);
readln(f1,s2);
close(f1);
l1:=length(s1);
l2:=length(s2);
for i:=1 to l1 do a[i]:=0;
for i:=1 to l2 do b[i]:=0;
for i:=1 to l1 do for k:=1 to l1 do if s1[i]=s1[k] then a[i]:=a[i]+1;
for i:=1 to l2 do for k:=1 to l2 do if s2[i]=s2[k] then b[i]:=b[i]+1;
for i:=1 to l1 do for k:=i to l1 do if a[i]<a[k] then
begin p:=a[i];a[i]:=a[k];a[k]:=p;end;
for i:=1 to l2 do for k:=i to l2 do if b[i]<b[k] then
begin p:=b[i];b[i]:=b[k];b[k]:=p;end;
j:=0;
for i:=1 to l1 do if a[i]=b[i] then j:=j+1;
if j=l1 then s3:='YES' else s3:='NO';
assign(f2,'ancient.out');rewrite(f2);
writeln(f2,s3);
close(f2);

end.
