{$APPTYPE CONSOLE}

uses
  SysUtils;
var   
  a,b:array[0..255] of integer;
  c,d:array[0..255] of integer;
  s,s1:string;
  flag:boolean;
  i:integer;

begin
  { TODO -oUser -cConsole Main : Insert code here }
  assign(input,'ancient.in');
  assign(output,'ancient.out');
  reset(input);
  rewrite(output);
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  readln(s);
  readln(s1);
  for i:=1 to length(s) do
    inc(a[ord(s[i])]);
  for i:=1 to length(s1) do
    inc(b[ord(s1[i])]);

  for i:=1 to 255 do
    begin
      inc(c[a[i]]);
      inc(d[b[i]]);
    end;
  flag:=false;
  for i:=0 to 255 do
    begin
      if c[i]<>d[i] then flag:=true;
    end;
  if flag=true then write('NO')
  else write('YES');

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