#include<iostream>
using namespace std;
bool check(string s1,string s2)
{
s1 +=s1;
if(s1.find(s2)!=s1.npos)
return 1;
else
return 0;
}
int main()
{
string s1,s2;
cin >> s1 >> s2;
if( check(s1,s2) || check(s2,s1))
cout << "true";
else
cout << "false";
return 0;
}