isGood :: Eq a => [a] -> Bool
isGood (x:xs) = all (\a -> a == x) xs

main = do
    ns <- fmap(read :: String -> Int) . words <$> getContents
    case () of
        _
            | 0 == (head ns) `mod` 1111 -> putStrLn "Yes" 
            | isGood (take 3 ns) -> putStrLn "Yes"
            | isGood (drop 1 ns) -> putStrLn "Yes"
            | otherwise -> putStrLn "No"