function Main(input){
	//var xs = input.split('\n')[0].split('')
    var xs = input.trim().split('').map(v=>parseInt(v,10));
    ans = '';
    if(xs[1]==xs[2]){
	if(xs[0]==xs[1]||xs[2]==xs[3]){
    ans += 'Yes';
    }else{
    ans += 'No';
    }
    }else{
    ans += 'No';  
	}
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));