"use strict";

function main(input) {

    input = input.split('').map(v => ~~v)

    let ans = 'No'
    if (input[0] == input[1] == input[2] || input[1] == input[2] == input[3]) ans = 'Yes'


    console.log(ans)

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