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

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

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

    private void solve() throws IOException {
        Locale.setDefault(Locale.US);
        in = new Scanner(new FileReader("given.in"));
        out = new PrintWriter("given.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;
        for (BitSet sh : shifts) {
            BitSet st = (BitSet) sh.clone();
            st.xor(t);
            if (shifts.contains(st)) {
                ok = true;
                break;
            }
        }
        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();
    }
}
