program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
  var
a,b:array[1..101] of integer;
i,j,m,k:integer;
s1,s2:string;
f,f1:text;
l1,l2:char;
flag:boolean;
sum:integer;
begin
assign(f,'ancient.in');
reset(f);
readln(f,s1);readln(f,s2);
close(f);

for i:=1 to length(s1) do
begin
l1:=s1[i];
sum:=0;
 for j:=i+1 to length(s1) do
 begin
 l2:=s1[j];
 if (l2=l1) and (l1<>' ') then
 begin
 s1[j]:=' ';
 sum:=sum+1;
 end;
 a[i]:=sum;
 end;
end;
for i:=1 to length(s2) do
begin
l1:=s2[i];
sum:=0;
 for j:=i+1 to length(s2) do
 begin
 l2:=s2[j];
 if (l2=l1) and (l1<>' ') then
 begin
 s2[j]:=' ';
 sum:=sum+1;
 end;
 b[i]:=sum;
 end;
end;
for i:=100 downto 1 do
begin
m:=0;
k:=0;
for j:=1 to i do
begin
if a[j]>m then begin m:=a[j];k:=j;end;
end;
m:=a[k];
a[k]:=a[i];
a[i]:=m;
end;
for i:=100 downto 1 do
begin
m:=0;
k:=0;
for j:=1 to i do
begin
if b[j]>m then begin m:=b[j];k:=j;end;
end;
m:=b[k];
b[k]:=b[i];
b[i]:=m;
end;
flag:=true;
for i:=1 to 100 do if a[i]<>b[i] then flag:=false;
assign(f1,'ancient.out');
rewrite(f1);
//for i:=1 to 100 do writeln(f1,b[i],a[i]);
if flag=true then write(f1,'YES') else write(f1,'NO');
close(f1);
end.
