{$R+,Q+,O-}
{$MINSTACKSIZE $00404000}
{$APPTYPE CONSOLE}
type
  int = longint;

var
  s1, s2: string;
  p1, p2: array [0..255] of int;
  tmp, n, j, i: int;
  
begin
  assign(input, 'ancient.in');
  assign(output, 'ancient.out');
  reset(input);
  rewrite(output);

  if seekeof then ;
  readln(s2);
  if seekeof then ;
  readln(s1);

  if (length(s1) <> length(s2)) then
  begin
    writeln('NO');
    exit;
  end;

  fillchar(p1, sizeof(p1), 0);
  for i:=1 to length(s1) do
    inc(p1[ord(s1[i])]);

  fillchar(p2, sizeof(p2), 0);
  for i:=1 to length(s2) do
    inc(p2[ord(s2[i])]);

  n:=length(s1);
  for i:=0 to 255 do
    for j:=0 to 255 - 1 do
      if (p1[j] < p1[j + 1]) then
      begin
        tmp:=p1[j];
        p1[j]:=p1[j + 1];
        p1[j + 1]:=tmp;
      end;

  for i:=0 to 255 do
    for j:=0 to 255 - 1 do
      if (p2[j] < p2[j + 1]) then
      begin
        tmp:=p2[j];
        p2[j]:=p2[j + 1];
        p2[j + 1]:=tmp;
      end;

  for i:=1 to n do
    if (p1[i] <> p2[i]) then
    begin
      writeln('NO');
      exit;
    end;

  writeln('YES');
end.

