{$APPTYPE CONSOLE}

program zzz;

var
  s1,s2: string;
  aa,bb: array[0..1000] of Longint;
  c1: char;
  i,j,k,n,m: Longint;
  a,b: array['A'..'Z'] of Longint;

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);
  fillchar(aa,sizeof(aa),0);
  fillchar(bb,sizeof(bb),0);
  for i := 1 to length(s1) do begin
    inc(a[s1[i]]);
  end;
  for i := 1 to length(s2) do inc(b[s2[i]]);
  for c1 := 'A' to 'Z' do begin
    inc(aa[a[c1]]);
  end;
  for c1 := 'A' to 'Z' do inc(bb[b[c1]]);
  for i := 1 to 1000 do begin
    if aa[i] <> bb[i] then begin
      writeln('NO');
      close(output);
      close(input);
      halt(0);
    end;
  end;
  writeln('YES');
  close(input);
  close(output);
end.