#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
const int maxm=100;
int nextable[maxm];
void getnext(string b){
	int m=b.size();
	int j=0;
	nextable[j]=-1;
	int t=nextable[j];
	while(j<m){
		if(t==-1||nextable[j]==nextable[t]){
			t++;j++;nextable[j]=t;
		}
		else t=nextable[t];
	}
	return;
}
bool KMP(string a,string b){
	getnext(b);
	int n=a.size(),m=b.size();
	int i=0,j=0;
	while(i<n&&j<m){
		if(j==-1||a[i]==b[j]){
			i++;
			j++;
		}
		else{
			j=nextable[j];
		}
	}
	if(j==m) return true;
	else return false;
}
int main(){
	string a,b;
	cin>>a>>b;
	a+=a;
	bool r=KMP(a,b);
	if(r) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}