{$APPTYPE CONSOLE}

var
  a, b : array[0..255] of integer;
  i, j, n : integer;
  s1, s2 : string;
begin
  assign(input, 'ancient.in'); reset(input);
  assign(output, 'ancient.out'); rewrite(output);
  n := 255;
  for i:=1 to n do a[i] := 0;
  for i:=1 to n do b[i] := 0;

  readln(s1); readln(s2);

  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:=n downto 2 do
    for j:=1 to i do
      if(a[j-1]>a[j])then begin
        a[j-1] := a[j]+a[j-1];
        a[j] := a[j-1]-a[j];
        a[j-1] := a[j-1]-a[j];
      end;
  for i:=n downto 2 do
    for j:=1 to i do
      if(b[j-1]>b[j])then begin
        b[j-1] := b[j]+b[j-1];
        b[j] := b[j-1]-b[j];
        b[j-1] := b[j-1]-b[j];
      end;
  for i:=1 to n do if a[i]<>b[i]then begin write('NO'); halt; end;
  write('YES');
end.
