fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var cnt = 1
    var kari = -1

    while(n != 0) {
        if(cnt == 3) break
        if(n % 10 == kari) {
            cnt++
        } else {
            kari = n % 10
            cnt = 1
        }
        n /= 10
    }

    print(if(cnt == 3) "Yes" else "No")
}