main = do
  n <- readLn
  if ((mod n 10 == mod (div n 10) 10) && (mod (div n 10) 10 == mod (div n 100) 10)) || ((mod (div n 10) 10 == mod (div n 100) 10) && (mod (div n 100) 10 == mod (div n 1000) 10))
    then putStrLn "Yes"
    else putStrLn "No"