{$APPTYPE CONSOLE}
type arr=array[1..26] of longint;
var a,b:string;
    p,q:arr;
    ans:boolean;

procedure readdata;
begin
 readln(a);
 readln(b);
end;

procedure swap(var a,b:longint);
var t:longint;
begin
 t:=a;a:=b;b:=t;
end;

procedure count(var a:string;var p:arr);
var i,j:longint;
begin
 fillchar(p,sizeof(p),0);
 for i:=1 to length(a) do
 if a[i] in ['A'..'Z'] then
  p[ord(a[i])-ord('A')+1]:=p[ord(a[i])-ord('A')+1]+1;
 for i:=1 to 26 do
 for j:=1 to 25 do
 if p[j]>p[j+1] then
  swap(p[j],p[j+1]); 
end;

procedure solve;
var i:longint;
begin
 count(a,p);
 count(b,q);
 ans:=true;
 for i:=1 to 26 do
 if p[i]<>q[i] then
  begin
   ans:=false;
   exit;
  end;
end;

procedure outdata;
begin
 if ans then
  writeln('YES')
 else
  writeln('NO'); 
end;

begin
 assign(input,'ancient.in');
 reset(input);
 assign(output,'ancient.out');
 rewrite(output);
 readdata;
 solve;
 outdata;
 close(output);
end.
