import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val input = new Scanner(System.in)
    val numCharList: List[Char] = input.nextInt.toString.toList

    if (numCharList(0) == numCharList(1) && numCharList(1) == numCharList(2)) {
      println("Yes")
    } else if (numCharList(1) == numCharList(2) && numCharList(2) == numCharList(3)) {
      println("Yes")
    } else {
      println("No")
    }
  }
}