
let string = readLine()!
let array = Array(string)


func isGoodInteger(array: [Character]) -> Bool {
    
    if array[0] == array[1] {
        if array[1] == array[2] {
            return true
        }
    }
    
    if array[1] == array[2] {
        if array[2] == array[3] {
            return true
        }
    }
    
    return false
}

if isGoodInteger(array: array) {
    print("Yes")
} else {
    print("No")
}

