program Project1;
{$APPTYPE CONSOLE}

var
  s1,s2:string;
  a1,a2:array['A'..'Z']of integer;
  c1,c2:array[0..100]of integer;
  t:boolean;

procedure init;
begin
        assignfile(input,'ancient.in');
        reset(input);
                fillchar(a1,sizeof(a1),0);
                fillchar(a2,sizeof(a2),0);
                fillchar(c1,sizeof(c1),0);
                fillchar(c2,sizeof(c2),0);
                readln(s1);
                readln(s2);
        closefile(input);
end;

procedure vivi;
begin
        assignfile(output,'ancient.out');
        rewrite(output);
          if t then begin
                writeln('YES');
          end
          else begin
                writeln('NO');
          end;
        closefile(output);
end;

procedure proc;
var
  i:integer;
  j:char;
begin
        for i:=1 to length(s1) do begin
                inc(a1[s1[i]]);
        end;
        for i:=1 to length(s2) do begin
                inc(a2[s2[i]]);
        end;
        for j:='A' to 'Z' do begin
          if a1[j]<>0 then inc(c1[a1[j]]);
          if a2[j]<>0 then inc(c2[a2[j]]);
        end;
        t:=true;
        for i:=0 to 100 do begin
          if c1[i]<>c2[i] then begin
            t:=false;
            break;
          end;
        end;
end;

begin
        init;
        proc;
        vivi;
end.
