program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var s1,s2:string;
    a1,a2:array[1..255] of word;
    i,j:word;
    mem:word;
begin
 assign(input,'ancient.in');
 reset(input);
  readln(s1);
  readln(s2);
 close(input);
 for i:=1 to 255 do
  begin
   a1[i]:=0;
   a2[i]:=0;
  end;
 if length(s1)=length(s2) then
 begin
 for i:=1 to length(s1) do
  begin
  inc(a1[ord(s1[i])]);
  inc(a2[ord(s2[i])]);
  end;
 for i:=1 to 255 do
  for j:=i to 255 do
   begin
    if a1[i]>a1[j] then begin
     mem:=a1[i];
     a1[i]:=a1[j];
     a1[j]:=mem;
    end;
    if a2[i]>a2[j] then begin
     mem:=a2[i];
     a2[i]:=a2[j];
     a2[j]:=mem;
    end;
   end;
  end;
  j:=0;
  assign(output,'ancient.out');
  rewrite(output);
  for i:=255 downto 1 do
   if a1[i]<>a2[i] then begin j:=1; break; end;
  if (j=0) and (length(s1)=length(s2)) then write('YES') else write('NO');
  close(output);
end.
