program ancient;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type kaa=record
man:integer;
boo:boolean;
end;
var inf,outf:textfile;ab,sb:array[1..26]of kaa;
S1,S2,ss,ss1:string;k,i,j:integer;aa,bb:set of byte;poo:boolean;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  assignfile(inf,'ancient.in');
  reset(inf);
  assignfile(outf,'ancient.out');
  rewrite(outf);
  readln(inf,s1);
  readln(inf,s2);
  k:=1;
  for i:=1 to 26 do
  begin
  ab[i].man:=0;
  ab[i].boo:=false;
  sb[i].man:=0;
  sb[i].boo:=false;
  end;
  for i:=1 to length(s1) do
  begin
  inc(ab[ord(s1[i])-64].man);
  inc(sb[ord(s2[i])-64].man);
  end;
  for i:=1 to 26 do
  for j:=1 to 26 do
  if ((ab[i].man=sb[j].man)and(sb[j].boo=false)and(ab[i].man<>0)and(ab[i].boo=false)) then
  begin
  ab[i].boo:=true;sb[j].boo:=true;
  end;
  poo:=true;
  for i:=1 to 26 do
  if ((ab[i].man<>0) and (ab[i].boo=false)) then poo:=false;
  if poo then writeln(outf,'YES') else writeln(outf,'NO');
  closefile(outf);
  closefile(inf);
end.
