program A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var x,y:array['A'..'Z'] of integer;

procedure solve;
var i,j:char;
    k:integer;
    ch:boolean;
begin
  for i:='A' to 'Y' do begin
    for j:=chr(ord(i)+1) to 'Z' do begin
      if x[j]<x[chr(ord(j)-1)] then begin
        k:=x[j]; x[j]:=x[chr(ord(j)-1)]; x[chr(ord(j)-1)]:=k;
      end;
    end;
  end;
  for i:='A' to 'Y' do begin
    for j:=chr(ord(i)+1) to 'Z' do begin
      if y[j]<y[chr(ord(j)-1)] then begin
        k:=y[j]; y[j]:=y[chr(ord(j)-1)]; y[chr(ord(j)-1)]:=k;
      end;
    end;
  end;
  ch:=true;
  for i:='A' to 'Z' do begin
    if x[i]<>y[i] then ch:=false;
  end;
  if ch then writeln('YES') else writeln('NO');
end;

procedure getDataDD;
var s1,s2:string;
    i:integer;
    c:char;
begin
  for c:='A' to 'Z' do begin
    x[c]:=0; y[c]:=0;
  end;
  readln(s1);
  readln(s2);
  if length(s1)<>0 then begin
    if (length(s1)<>length(s2)) then writeln('NO')
    else begin
      for i:=1 to length(s1) do begin
        inc(x[s1[i]]);
        inc(y[s2[i]]);
      end;
      solve;
    end;
  end;  
end;

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