function Main(input){
  input = input.split("\n");
  tmp = input[0]
  var goodNumberFlag = false;
  
  if(tmp[0] == tmp[1] && tmp[1] == tmp[2]){
    goodNumberFlag = true;
  }else if(tmp[1] == tmp[2] && tmp[2] == tmp[3]){
    goodNumberFlag = true;
  }
  
  if(goodNumberFlag){
    console.log('Yes');
  }else{
    console.log('No');
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));