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

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

    public void run() {
        String t = in.nextLine();
        String s = in.nextLine();
        s = s + s + s;

        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 && t.charAt(q + 1) != t.charAt(i)) q = p[q];
            if (t.charAt(q + 1) == t.charAt(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' + (s.charAt(j) ^ s.charAt(i + j)));
                while (q != -1 && t.charAt(q + 1) != ch) q = p[q];
                if (t.charAt(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_string().run();

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