function main(input) {
    const args = input.split('');
    const sen = args[0];
    const hyaku = args[1];
    const jyu = args[2];
    const ichi = args[3];

    if (sen === hyaku) {
        if (hyaku === jyu) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else if (hyaku === jyu) {
        if (jyu === ichi) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else {
        console.log('No');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));