program a1;

{$APPTYPE CONSOLE}

uses SysUtils;

var a,b:array[0..300] of integer;
    s:string;
    i,j,n,n1,n2,m:integer;

begin
  assign(input, 'ancient.in');
  reset(input);
  assign(output, 'ancient.out');
  rewrite(output);

  fillchar(a, sizeof(a), 0);
  fillchar(b, sizeof(b), 0);

  readln(s);
  n1:=length(s);
  for i:=1 to n1 do
  begin
    inc(a[ord(s[i])]);
  end;

  readln(s);
  n2:=length(s);
  for i:=1 to n2 do
  begin
    inc(b[ord(s[i])]);
  end;

  if(n1<>n2) then
  begin
    writeln('NO');
    close(output);
    exit;
  end;

  n:=256;
  
  for i:=1 to n-1 do
  begin
    m:=i;
    for j:=i+1 to n do
    begin
      if a[j]>a[m] then m:=j;
    end;
    if(m>i) then
    begin
      a[0]:=a[m];
      a[m]:=a[i];
      a[i]:=a[0];
    end;
  end;

  for i:=1 to n-1 do
  begin
    m:=i;
    for j:=i+1 to n do
    begin
      if b[j]>b[m] then m:=j;
    end;
    if(m>i) then
    begin
      b[0]:=b[m];
      b[m]:=b[i];
      b[i]:=b[0];
    end;
  end;

  for i:=1 to n do
    if(a[i]<>b[i]) then
    begin
      writeln('NO');
      close(output);
      exit;
    end;


  writeln('YES');


  close(input);
  close(output);
end.
