program Project1;

{$APPTYPE CONSOLE}


var s1,s2,s3:string;
    k,s:char;
    mas1,mas2:array['A'..'Z'] of longint;
    mas3,mas4:array[0..100] of longint;
    d,i,j,t:longint;
    otv:boolean;
begin
  assign(input,'ancient.in');
  reset(input);
  assign(output,'ancient.out');
  rewrite(output);
  readln(s1);
  readln(s2);
  d:=length(s1);
  for i:=1 to d do
    begin
    inc(mas2[s2[i]]);
    inc(mas1[s1[i]]);
    end;
  for k:='A' to 'Z' do
    begin
      inc(mas3[mas1[k]]);
      inc(mas4[mas2[k]]);
    end;
  otv:=true;
  for i:=1 to 100 do
    if mas3[i]<>mas4[i] then
      otv:=false;

  if otv then write('YES') else write('NO');
  close(input);
  close(output);

end.
