toInt :: String -> Int
toInt = read :: String -> Int

lucas :: [Int]
lucas = 2 : 1 : zipWith (+) lucas (tail lucas)

isGoodNumber :: Int -> Bool
isGoodNumber n = mod (div n 10) 111 == 0 || mod (mod n 1000) 111 == 0 

main = do
  n <- toInt <$> getLine
  putStrLn $ if isGoodNumber n then "Yes" else "No"
