import java.util.*

/**
 * Created on 2017/09/09.
 */
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val int = sc.nextInt()
    var list = Array<Int>(4) { 0 }
    for (i in 0..3) {
        list[i] = (int / (Math.pow(10.0, i.toDouble())).toInt()) % 10
    }
    if((list[0] == list[1] && list[1] == list[2]) || (list[1] == list[2] && list[2] == list[3]) ) println("Yes")
    else println("No")
}