'use strict'

function main(s) {

  const n = s.split('\n')[0].split('');

  const pattern1 = n[0] === n[1] && n[1] === n[2] && n[2] !== n[3];
  const pattern2 = n[0] !== n[1] && n[1] === n[2] && n[2] === n[3];
  const pattern3 = n[0] === n[1] && n[1] === n[2] && n[2] === n[3];

  const ans = pattern1 || pattern2 || pattern3;
  console.log(ans ? 'Yes' : 'No');
}

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