import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String A = br.readLine();
		String B = br.readLine();
		int lengths = A.length();
		//boolean Ab[] = new boolean[lengths];
		boolean Bb[] = new boolean[lengths];
		for(int i = 0; i < lengths; i++)
		{
			//Ab[i] = false;
			Bb[i] = false;
		}
		int k = 0;
		for(int i = 0;i < lengths;i++)
		{
			//System.out.println(i);
			if(i == 0)
			{
				for(int j = 0;;j++)
				{
					//System.out.println(A.substring(i, i+1).equals(B.substring(j, j+1)) + " " + A.substring(i, i+1) + " " + B);
					if(j == lengths)
					{
						System.out.println("No");
						System.exit(0);
					}
					if(!Bb[j] && A.substring(i, i+1).equals(B.substring(j, j+1)))
					{
						Bb[j] = true;
						k = j;
						break;
					}
				}
			}
			else
			{
				int l = k+i >= lengths ? k+i-lengths : k+i;
				//System.out.println(l + " " + i + " " + k + " " + lengths);
				if(!A.substring(i, i+1).equals(B.substring(l, l+1)))
				{
					i = -1;
				}
			}
		}
		System.out.println("Yes");
	}

}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz