import io.{StdIn => in}

object Main extends App {
  val n = in.readLine
  val ans = n match {
    case s if n.init.forall(_ == n.head) => "Yes"
    case s if n.tail.forall(_ == n.last) => "Yes"
    case _ => "No"
  }
  println(ans)
}