#include<iostream>
using namespace std;
int main()
{
string str,ces;
cin>>str>>ces;
if(str.size()<ces.size()) swap(str,ces);
for(int i=0;i<str.size();i++)
{
int j=0;
while(str[j]==ces[j]&&j<ces.size()) j++;
if(j==ces.size()) {cout<<"true"; return 0;}
str=str.substr(1,str.size()-1)+str[0];
}
cout<<"false";
return 0;
}