import scala.io.StdIn._
 
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val n = sc.next
  if((n(0)==n(1))&&(n(1)==n(2))||(n(1)==n(2))&&(n(2)==n(3))){
    println("Yes")
  }
  else{
    println("No")
  }  
}