{$APPTYPE CONSOLE}

Type SM=Array [#0..#255] of integer;
Var S1,S2,ns2 : String;
    A,b : SM;

Procedure MakeSm(S : String;Var A : Sm);
  Var I : integer;
 begin
  fillchar(a,sizeof(a),0);
   for i:=1 to length(s) do inc(a[s[i]]);
 End;

Procedure Swap(Var a,b : integer);
  Var f : integer;
 begin
  f:=a;
  a:=b;
  b:=f;
 End;

Procedure Sort(Var A : sm);
  Var c1,c2 : Char;
 begin
  for c1:=#0 to #255 do
   for c2:=#0 to #255 do
    if a[c1]>a[c2] then swap(a[c1],a[c2]);
 End;

Procedure Compare;
  var c : char;
 Begin
 Sort(A);
 Sort(b);
  for c:=#0 to #255 do
   if a[c]<>b[c] then exit;
   writeln('YES');
   halt(0);
 End;

Procedure Solve;
  Var I,j,num : integer;
 Begin
  for i:=0 to 25 do
   Begin
     MakeSm(s1,A);
      ns2:=s2;
      for j:=1 to length(s2) do
       Begin
        num:=ord(s2[j])-Ord('A');
        num:=(num+i) mod 26;
        ns2[j]:=chr(num+Ord('A'));
       End;
     MakeSm(ns2,b);
     compare;
   End;
  writeln('NO');
 End;

begin
 Assign(input,'ancient.in');Reset(input);
 Assign(output,'ancient.out');Rewrite(output);
 readln(s1);
 readln(s2);
 Solve;
end.

