program proga;

{$APPTYPE CONSOLE}

type ar = array['A'..'Z'] of byte;

var f: text;
    a1, a2: ar;
    s1, s2: string;

procedure calculate (s: string; var a: ar);
  var i: byte;
      c1, c2: char;
begin
  fillchar (a, sizeof(a), 0);
  for i := 1 to length (s) do
    inc (a[s[i]]);
  for c1 := 'A' to 'Z' do
    for c2 := chr(ord(c1)+1) to 'Z' do
    if (a[c1] < a[c2]) then
    begin
      i := a[c2];
      a[c2] := a[c1];
      a[c1] := i;
    end;
end;

var cool: boolean;
    c: char;
begin
  assign (f, 'ancient.in');
  reset (f);
  readln (f, s1);
  readln (f, s2);
  close (f);

  calculate (s1, a1);
  calculate (s2, a2);

  cool := true;
  for c := 'A' to 'Z' do
  if (a1[c] <> a2[c]) then
  begin
    cool:= false;
    break;
  end;



  assign (f, 'ancient.out');
  rewrite (f);
  if cool then writeln (f,'YES') else writeln (f, 'NO');
  close (f);

end.
