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

public class given_md implements Runnable {
	private Scanner in;
	private PrintWriter out;

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private void solve() {
		Locale.setDefault(Locale.US);
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		String t1 = in.next();
		String s1 = in.next();
		int n = s1.length();
		BitSet ss = stringToBitSet(s1 + s1);
		BitSet t = stringToBitSet(t1);
		HashSet<BitSet> shifts = new HashSet<BitSet>();
		for (int i = 0; i < n; i++) {
			BitSet sh = ss.get(i, i + n);
			shifts.add(sh);
		}
		boolean ok = false;
		main:
		for (BitSet sh : shifts) {
			for (BitSet sh2 : shifts) {
				BitSet or = (BitSet) sh.clone();
				or.or(sh2);
				if (or.equals(t)) {
					ok = true;
					break main;
				}
			}
		}
		if (ok)
			out.println("Yes");
		else
			out.println("No");
		in.close();
		out.close();
	}

	private BitSet stringToBitSet(String s) {
		BitSet result = new BitSet(s.length());
		for (int i = 0; i < s.length(); i++)
			if (s.charAt(i) == '1')
				result.set(i);
		return result;
	}

	public static void main(String[] args) {
		new Thread(new given_md()).start();
	}
}
