process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var digits = input[0].split('');

    var maxContNum = 0;
    var contNum = 1;
    for (var i = 1; i < digits.length; i++) {
        if (digits[i] == digits[i - 1]) {
            contNum++;
        }
        else {
            maxContNum = Math.max(maxContNum, contNum);
            contNum = 1;
        }
    }
    maxContNum = Math.max(maxContNum, contNum);

    if (maxContNum >= 3) {
        console.log('Yes');
    }
    else {
        console.log('No');
    }

    return 0;
}
