{$I+,O-,Q-,R-,S-}

const
  cinfile = 'ancient.in';
  coutfile = 'ancient.out';

type
  int = longint;
  real = extended;
  float = extended;

var
  n, k, m : int;
  ans : int;

  c1, c2 : array [#0..#255] of int;
  p1, p2 : array [0..1000] of int;

  s1, s2 : string;

procedure outdata;
var
  i, j : int;
begin
  if ans = 1 then writeln('YES') else writeln('NO');
end;

procedure solve;
var
  i, j : int;
  c : char;
begin
  fillchar(c1, sizeof(c1), 0);
  c2:= c1;
  for i:= 1 to length(s1) do inc(c1[s1[i]]);
  for i:= 1 to length(s2) do inc(c2[s2[i]]);
  for c:= #0 to #255 do inc(p1[c1[c]]);
  for c:= #0 to #255 do inc(p2[c2[c]]);
  ans:= 1;
  for i:= 0 to 1000 do
    if p1[i] <> p2[i] then ans:= 0;
end;

procedure readdata;
var
  i, j : int;
begin
  readln(s1);
  readln(s2);
end;

begin
  reset(input, cinfile);
  rewrite(output, coutfile);
  readdata;
  solve;
  outdata;
  close(output);
  close(input);
end.
