import io.{StdIn => in}

object Main extends App {
  val n = in.readInt.toString.toCharArray
  val ans = n match {
    case s if s(0) == s(1) && s(1) == s(2) => "Yes"
    case s if s(1) == s(2) && s(2) == s(3) => "Yes"
    case _ => "No"
  }
  println(ans)
}