{$O+,Q-,R-}
uses SysUtils, Math;

const MaxN = 5000;

var n : integer;

function sxor (const x, y : string) : string;
var i : integer;
begin
  setlength (Result, n);
  for i := 1 to n do Result [i] := chr (ord (x[i] <> y[i]) + 48);
end;

var i, j : integer;
    s1, s2 : string;

begin
  readln (s1); readln (s2); 
  assert (length (s1) = length (s2));
  assert (eof);
  n := length (s1);
  assert ((n >= 1) and (n <= MaxN));
  for i := 1 to n do assert (s1[i] in ['0', '1']);
  for i := 1 to n do assert (s2[i] in ['0', '1']);
  for i := 1 to n do 
    for j := i to n do
      if sxor (copy (s2, i, n) + copy (s2, 1, i - 1), copy (s2, j, n) + copy (s2, 1, j - 1)) = s1 then begin
        writeln ('Yes'); halt
      end;
  writeln ('No');
end.