program Task_A;

{$APPTYPE CONSOLE}

var
  S1, S2: String;
  Mas1, Mas2: array[1..26] of Integer;
  N, i, j, T: Integer;

begin
  Assign(input, 'ancient.in');
  Reset(input);
  Assign(output, 'ancient.out');
  ReWrite(output);
  ReadLn(S1);
  ReadLn(S2);
  N := Length(S1);
  for i := 1 to 26 do
    begin
      Mas1[i] := 0;
      Mas2[i] := 0;
    end;
  for i := 1 to N do
    begin
      Inc(Mas1[Ord(S1[i]) - Ord('A') + 1]);
      Inc(Mas2[Ord(S2[i]) - Ord('A') + 1]);
    end;
  N := 26;  
  for i := 1 to N - 1 do
    begin
      j := i + 1;
      T := Mas1[j];
      while (j > 1) and (T > Mas1[j - 1]) do
        begin
          Mas1[j] := Mas1[j - 1];
          Dec(j);
        end;
      Mas1[j] := T;
    end;
  for i := 1 to N - 1 do
    begin
      j := i + 1;
      T := Mas2[j];
      while (j > 1) and (T > Mas2[j - 1]) do
        begin
          Mas2[j] := Mas2[j - 1];
          Dec(j);
        end;
      Mas2[j] := T;
    end;
  i := 1;
  while (i <= N) and (Mas1[i] = Mas2[i]) do
    Inc(i);
  if i <= N then
    WriteLn('NO')
  else
    WriteLn('YES');
end.

