program a;

{$APPTYPE CONSOLE}

{$DEFINE DEBUGwe}


uses
  SysUtils;
const
  TaskName = 'ancient';

var
  i, j, k, n : Integer;
  s1, s2 : string;
  Ans : Boolean;

procedure Solve();
  var
    i, j, k, n : Integer;
    F1, F2 : array [ 0 .. 255 ] of Integer;
  begin
    Ans := false;
    if Length(S1) <> Length(s2)
      then
        Exit;
    for i := 0 to 255 do
      F1[i] := 0;
    for i := 0 to 255 do
      F2[i] := 0;
    for i := 1 to Length(s1) do
      Inc(F1[Ord(s1[i])]);
    for i := 1 to Length(s2) do
      Inc(F2[Ord(s2[i])]);
    for i := 1 to 255 do
      for j := (i+1) to 255 do
        if not (F1[i] >= F1[j])
          then
            begin
              k := F1[i];
              F1[i] := F1[j];
              F1[j] := k;
            end;
    for i := 1 to 255 do
      for j := (i+1) to 255 do
        if not (F2[i] >= F2[j])
          then
            begin
              k := F2[i];
              F2[i] := F2[j];
              F2[j] := k;
            end;
    Ans := true;
    for i := 0 to 255 do
      Ans := Ans and (F1[i] = F2[i]);



  end;

begin
{$IFNDEF DEBUG}
  Assign( input, TaskName + '.in' );
  Assign( output, TaskName + '.out' );
  Reset(input);
  Rewrite(output);
{$ENDIF}

  ReadLn(S1);
  ReadLn(S2);

  Solve();

  if Ans
    then
      WriteLn('YES')
    else
      WriteLn('NO');

{$IFNDEF DEBUG}
  Close(input);
  Close(output);
{$ELSE}
  ReadLn;
{$ENDIF}
end.
