program blank;

{$APPTYPE CONSOLE}

uses
  SysUtils;
const
  taskid='ancient';
  infile=taskid+'.in';
  outfile=taskid+'.out';

var
  s1,s2:string;
  c1,c2:array[0..255] of longint;

Procedure done(f:boolean);
begin
  if f then
    writeln('YES')
  else
    writeln('NO');
  close(input);  close(output);
  halt(0);
end;
{--------------------------------------------------------------------}
Procedure Lesen;
Begin
  readln(s1);
  readln(s2);
  if length(s1)<>length(s2) then
    done(false);
end;
{--------------------------------------------------------------------}
Procedure Run;
var
  i,j,n:longint;
Begin
  fillchar(c1,sizeof(c1),0);
  fillchar(c2,sizeof(c2),0);
  n:=length(s1);
  for i:=1 to n do
  begin
    inc(c1[ord(s1[i])]);
    inc(c2[ord(s2[i])]);
  end;
  for i:=1 to 254 do
  begin
    for j:=i+1 to 255 do
    begin
      if c1[i]<c1[j] then
      begin
        c1[i]:=c1[i]+c1[j];
        c1[j]:=c1[i]-c1[j];
        c1[i]:=c1[i]-c1[j];
      end;
    end;
  end;
  for i:=1 to 254 do
  begin
    for j:=i+1 to 255 do
    begin
      if c2[i]<c2[j] then
      begin
        c2[i]:=c2[i]+c2[j];
        c2[j]:=c2[i]-c2[j];
        c2[i]:=c2[i]-c2[j];
      end;
    end;
  end;
  for i:=0 to 255 do
    if c1[i]<>c2[i] then
      done(false);
  done(true);    
end;
{--------------------------------------------------------------------}
begin
  assign(input,infile);  reset(input);
  assign(output,outfile);  rewrite(output);
  lesen;
  run;
end.
