{$O-,R+,Q+}

type
  nums = array[0..25] of integer;

var
 j, i,n:longint;
 a, b:nums;

procedure read_num( var x: nums );
 var
   s: string;
   i: integer;
 begin
   readln(s);
   for i := 1 to length(s) do
     inc( x[ ord(s[i]) - ord('A' ) ] );
 end;

 var
   ok: boolean;

procedure srt( var x: nums );
  var
    y, i, j: integer;
  begin
    for i := 0 to 25 do for j := i + 1 to 25 do if x[i] > x[j] then begin
      y := x[i];
      x[i] := x[j];
      x[j] := y; 
    end;
  end;

begin
 assign(input,'ancient.in'); reset(input);
 assign(output,'ancient.out'); rewrite(output);
 read_num(a );
 read_num(b);
 srt( a );
 srt( b );
 for i := 0 to 25 do begin
   ok := true;
   for j := 0 to 25 do
     if a[(i+j) mod 26] <> b[j] then ok := false;
   if ok then begin
     writeln('YES');
     halt;
   end;
 end;
 writeln( 'NO' );
end.
