var fin,fout:textfile;
    mass1,mass2:array[1..26] of longint;
    i,j,k:integer;
    s:string;
begin
  assignfile(fin,'ancient.in');
  assignfile(fout,'ancient.out');
  reset(fin);
  rewrite(fout);

  readln(fin,s);
  k:=length(s);

  for i:=1 to 26 do begin mass1[i]:=0;mass2[i]:=0;end;

  for i:=1 to k do
  begin
    j:=ord(s[i])-ord('A')+1;
    mass1[j]:=mass1[j]+1;
    if (j<1) or (j>26) then writeln(j/(j-j));
  end;
  
  readln(fin,s);
  k:=length(s);

  for i:=1 to k do
  begin
    j:=ord(s[i])-ord('A')+1;
    mass2[j]:=mass2[j]+1;
    if (j<1) or (j>26) then writeln(j/(j-j));
  end;


  for i:=1 to 26 do
     for j:=2 to 26 do
         begin
            if mass1[j]<mass1[j-1] then begin k:=mass1[j]; mass1[j]:=mass1[j-1];mass1[j-1]:=k; end;
            if mass2[j]<mass2[j-1] then begin k:=mass2[j]; mass2[j]:=mass2[j-1];mass2[j-1]:=k; end;
         end;

{  for i:=1 to 26 do 
  begin
     write(mass1[i],' ');
  end;
  writeln;
  for i:=1 to 26 do 
  begin
     write(mass2[i],' ');
  end;
 writeln;}


  k:=0;

  for i:=1 to 26 do 
  begin
    if mass1[i]<>mass2[i] then k:=k+1;
  end;

  if k=0 then writeln(fout,'YES') else writeln(fout,'NO');
  closefile(fin);
  closefile(fout);
end.
