function main(input) {
  input=input.trim();
  const n = parseInt(input.split(" ")[0], 10);
  const a = Math.floor(n/10);
  const b = n%1000;
  if(a%111==0 || b%111==0){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

