const 
    max_n = 5000;

var 
    n, i, j: longint;
    t, s: string;
    p: array [0..max_n] of longint;
    q: longint;
    found: boolean;
    ch: char;

function next(q: longint; ch: char): longint;
begin
    while (q > 0) and (ch <> t[q + 1]) do begin
        q := p[q];
    end;
    if (ch = t[q + 1]) then begin
        inc(q);
    end;
    next := q;
end;

begin
    readln(t); 
    readln(s); 
    n := length(t);

    p[0] := 0;
    p[1] := 0;
    for i := 2 to n do begin
        p[i] := next(p[i - 1], t[i]);
    end;

    s := s + s + s;

    found := false;
    for i := 1 to n do begin
        q := 0;
        for j := 1 to 2 * n do begin
            q := next(q, chr(ord('0') + (ord(s[j]) xor ord(s[i + j]))));
            if q = n then begin
                found := true;
                q := p[q];
            end;
        end;
    end;

    if (found) then begin
        writeln('Yes');
    end else begin
        writeln('No');
    end;

    close(input);
    close(output);
end.