program ancient;
const
 maxn=102;
var
 s1,s2:string;
 a,b:array[32..255] of longint;
 i,j:integer;
 t:longint;
 flag:boolean;
begin
  assign(input,'ancient.in');
  reset(input);
  assign(output,'ancient.out');
  rewrite(output);

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

  for i:=32 to 255 do
  begin
    for j:=i+1 to 255 do
    BEGIN
      if a[i]>a[j] then
      begin
        t:=a[i];
        a[i]:=a[j];
        a[j]:=t;
      end;
      if b[i]>b[j] then
      begin
        t:=b[i];
        b[i]:=b[j];
        b[j]:=t;
      end;
    END;
  end;

  flag:=true;
  for i:=32 to 255 do if a[i]<>b[i] then flag:=false;

  if flag then writeln('YES') else writeln('NO');
  close(input);
  close(output);
end.
