import java.io.*;
import java.util.*;

public class given_gk_array {
    static Scanner in;
    static PrintWriter out;

    public void run() {
        String t = in.nextLine();
        String s = in.nextLine();
        s = s + s + s;
        char[] ta = t.toCharArray();
        char[] sa = s.toCharArray();

        int n = t.length();

        int[] p = new int[n];
        p[0] = -1;
        int q = -1;
        for (int i = 1; i < n; i++) {
            while (q != -1 && ta[q + 1] != ta[i]) q = p[q];
            if (ta[(q + 1)] == ta[i]) {
                q++;
            }
            p[i] = q;
        }

        boolean ok = false;
        for (int i = 0; i < n; i++) {
            q = -1;
            for (int j = 0; j < 2 * n; j++) {
                char ch = (char) ('0' + (sa[j] ^ sa[i + j]));
                while (q != -1 && ta[q + 1] != ch) q = p[q];
                if (ta[q + 1] == ch) {
                    q++;
                    if (q == n - 1) {
                        ok = true;
                        q = p[q];
                    }
                }
            }
        }

        out.println(ok ? "Yes" : "No");
    }

    public static void main(String[] args) throws IOException {
        in = new Scanner(new File("given.in"));
        out = new PrintWriter("given.out");

        new given_gk_array().run();

        in.close();
        out.close();
    }
}
