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;

{  for i:=0 to 25 do
    begin
      otv:=true;
      fillchar(mas1,sizeof(mas1),0);
      s3:='';

      for j:=1 to d do
        begin
          {if s1[j]='Z' then
            s3:=s3+'A' else
              begin
                s:=s1[j];
                t:=ord(s)+i;
                if t>90 then
                  t:=t-25;
                s:=chr(t);
                s3:=s3+s;
              end;
        inc(mas1[s3[j]]);
        END;

        for k:='A' to 'Z' do
          if mas1[k]<>mas2[k] then
            begin
            otv:=false;
            end;

         if otv then break;

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

end.
