import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  s <- getLine
  putStrLn $ if (s !! 1 == s !! 2) && ((s !! 0 == s !! 1) || (s !! 2 == s !! 3)) then "Yes" else "No"

  