function Main(input) {
var a=(input+'').substr(0,3);
var b=(input+'').substr(1,3);
var c=['000','111','222','333','444','555','666','777','888','999'];
console.log(c.indexOf(a)+c.indexOf(b)>-1?'Yes':'No');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));