program a;

{$APPTYPE CONSOLE}

const fname = 'ancient';
      ifile = fname + '.in';
      ofile = fname + '.out';

var s1,s2: string;
    mas: array[1..2,char]of longint;
    mm: array[1..2,0..1000]of longint;

procedure load();
begin
  readln(s1);
  readln(s2);
end;

procedure solve();
var k: longint;
    c: char;
begin
  for k:=1 to length(s1) do
    inc(mas[1,s1[k]]);
  for k:=1 to length(s2) do
    inc(mas[2,s2[k]]);
  for c:=#0 to #255 do
    inc(mm[1,mas[1,c]]);
  for c:=#0 to #255 do
    inc(mm[2,mas[2,c]]);
  for k:=1 to 100 do
    if mm[1,k]<>mm[2,k] then begin
      writeln('NO');
      exit;
    end;
  writeln('YES');
end;

procedure save();
begin

end;

begin
  assign(input,ifile);
  reset(input);
  assign(output,ofile);
  rewrite(output);
  load;
  solve;
  save;
end.
 