program main
	integer i
	character(100) S, T
	character last
	read(*, *) S, T	
	do i = 1, 110
		if(trim(S) == trim(T)) then
			write(*, *) 'Yes'
			exit
		else
			last = S(len_trim(S):len_trim(S))
			S = last // S(1:len_trim(S)-1)
		end if
		if(i == 110) then
			write(*, *) 'No'
		end if
	end do
end program main