function Main(input) {
  const num = parseInt(input);
  
  const a = Math.floor(num / 1000);
  const b = Math.floor((num / 100) % 10);
  const c = Math.floor((num / 10) % 10);
  const d = num % 10;

  const answer = (a == b == c) || (b == c == d) ? 'Yes' : 'No';

  //出力
  console.log(answer);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));