program ancient;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type
 TT=array[1..26] of byte;

var
 a,a1:TT;
 i,j,n:integer;
 fin,fout:textfile;
 s1,s2:string[100];

procedure count(var v:TT;s:string);
var
 i,j,n:byte;
begin
 fillchar(v,sizeof(v),0);
 n:=length(s);
 for i:=1 to n do
  for j:=1 to 26 do
  if copy(s,i,1)=chr(j+64) then inc(v[j]);

end;

procedure sort(var v:TT);
var
 i,j,n,t:byte;
begin
 for i:=1 to 26 do
  for j:=1 to 25 do
  if (v[j]>v[j+1]) then
  begin
   t:=v[j];
   v[j]:=v[j+1];
   v[j+1]:=t;
  end;
end;




begin
 assignfile(fin,'ancient.in');
 assignfile(fout,'ancient.out');
 reset(FIN);
 REWRITE(FOUT);
 readln(fin,s1);
 readln(fin,s2);
// writeln(fout,s1,' ',s2);
 count(a,s1);
 count(a1,s2);
 sort(a);sort(a1);
 j:=0;
 for i:=1 to 26 do
 BEGIN
//  writeln(fout,a[i],' ',a1[i]);
 if a[i]<>a1[i] then j:=1;
 end;
 if j=0 then writeln(fout,'YES') else writeln(fout,'NO');
 closefile(fin);
 closefile(fout);

  { TODO -oUser -cConsole Main : Insert code here }
end.
