#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  if (s.length() != t.length()) {
    cout << "NO";
    return 0;
  }
  for (int d = 0; d < s.length(); d++) {
    int i = 0;
    while (s[i] == t[(i + d) % t.length()]) i++;
    if (i == s.length()) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
