import Text.Regex
import Text.Regex.Posix

main = do
  s <- getLine
  p <- getLine
  putStrLn $ if solve (s++s) p then "Yes"
             else "No"

solve :: String -> String -> Bool
solve a@(x:xs) p
  | length(a) < length(p) = False
  | (slice 0 (length p) a) == p = True
  | otherwise = solve xs p           
  where slice ::  Int -> Int -> String -> String
        slice m n s = (take (n-m) . drop m) $ s

solve2 :: String -> String -> Bool
solve2 ss p = ss =~ p