const alf: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var s,shif:string;
ch:byte;
 i,j:integer;
   f:textfile;
   a,b:array[1..26] of byte;

Function Count(ch:char; st:string):byte;
Var
     K:byte;
Begin
     RESULT:=0;
     for K:=1 to length(st) do if ch=st[K] then INC(RESULT);
End;

BEGIN
     assignfile(f,'ancient.in');
     reset(f);
     readln(f,shif);
     readln(f,s);
     closefile(f);

 assignfile(f,'ancient.out');
 rewrite(f);
 for i:=1 to 26 do
 begin
      a[i]:=count(alf[i],shif);
      b[i]:=count(alf[i],s);
 end;
    //sort
 for i:=1 to 25 do
    for j:=i+1 to 26 do
    begin
         if a[i]>a[j] then
         begin
              ch:=a[j];
              a[j]:=a[i];
              a[i]:=ch;
         end;

         if b[i]>b[j] then
         begin
              ch:=b[j];
              b[j]:=b[i];
              b[i]:=ch;
         end;
    end;

 J:=0;
 for i :=1 to 26 do
  begin
     if a[i]<>b[i] then J:=2;
  end;

 if (J=0)then
    writeln(f,'YES')
    else writeln(f,'NO');
 closefile(f);
END.
