function Main (input) {
    var rows  = input.split("\n")
    var num = rows[0]
    var same_count = 1
    var just_before_loaded = ""

    num.split("").map( function (c, index) {

        if (just_before_loaded == c) {
            same_count += 1
        } else {
            if (same_count < 3 ) same_count = 1
        }
        
        just_before_loaded = c
    })

    if (same_count >= 3 ) {
        console.log("Yes")
    } else {
        console.log("No")
    }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

