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

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

    int diff;

    int next(int hash, char ch, char pch) {
        return (hash << 1) ^ (hash >>> 31) ^ (17 * (ch - '0')) ^ (diff * (pch - '0'));
    }

    int hash(char[] chars, int offset, int length) {
        int hash = 0;
        for (int i = 0; i < length; i++) {
            hash = next(hash, chars[offset + i], '0');
        }
        return hash;
    }

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

        int n = t.length;

        diff = next(0, '1', '0');
        for (int i = 0; i < n; i++) {
            diff = next(diff, '0', '0');
        }


        Set<Integer> hashes = new HashSet<Integer>();

        int[] hash = new int[n];
        for (int i = 0, h = hash(s, 0, n); i < n; i++) {
            hash[i] = h;
            hashes.add(h);
            h = next(h, s[i + n], s[i]);
        }

        int thash = hash(t, 0, n);

        boolean ok = false;
        for (int i = 0; i < n; i++) {
            ok |= hashes.contains(hash[i] ^ thash);
        }

        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_hash().run();

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