object Main extends App {
  val list = readLine.split("").filter(_.nonEmpty)
  
  val result = list.drop(1).distinct.length == 1 || list.dropRight(1).distinct.length == 1
  println(if (result) "Yes" else "No")
}