program a;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  F : Text;
  ch : Char;
  C, i, j, k, l, p : Integer;
  s, s1, s2, s3 : String;
  N : Integer;
  m : Integer;
  Flag, prFlag : Boolean;
begin

  Assign(F, 'ancient.in');
  Reset(F);
  Readln(F, s3);
  Readln(F, s1);

  Close(F);

  N := length(S3);
  Flag := False;
  m := 0;

  While ((m < 27) and (not(Flag))) do begin
    s := s3;
    s2 := s1;
    prFlag := False;

    for i := 1 to N do begin
      l := 0;
      p := 0;
      C := (Ord(S[i]) + m - 65) mod 26 + 65;
      Ch := Chr(C);

      for j := 1 to N do begin
        if S[i] = S2[j] then L := j;
        if ch = S2[j] then p := j;
      end;

      if (p = 0) and (l = 0) then prflag := true;
      if (p = 0) and (l <> 0) then begin
        s[i] := '=';
        S2[l] := '=';
      end;
      if (l = 0) and (p <> 0) then begin
        s[i] := '=';
        S2[p] := '=';
      end;
{======================================================}
      for j := 1 to n do begin
        if s[i] <> '=' then begin
          if S[i] = S2[j] then L := j;
          if ch = S2[j] then p := j;
        end;
      end;
      if p <> 0 then begin
        s[i] := '=';
        S2[p] := '=';
      end;
      if (l <> 0) and (p = 0) then begin
        s[i] := '=';
        S2[l] := '=';
      end;

{======================================================}

    end;

    for i := 1 to N do begin
      if s2[i] <> '=' then PrFlag := True;
    end;
//  Writeln(m, ' RRR ', S2) ;


    inc(m);
    if Not(PrFlag) then flag := True;
  end;

//  Writeln(m, ' ! ', S2) else Writeln(m, ' sdfffff ', S2,  '  ', S1);
//  Readln;

  Assign(F, 'ancient.out');
  ReWrite(F);
  if flag then Write(F, 'YES') else Write(F, 'NO');


  Close(F);
end.
