import std.stdio;
import std.algorithm;
import std.range;
import std.array;
import std.string;

void main(){
	auto num_str = readln.chop;
	auto check_tri = (string target){
		return target[0] == target[1] && target[1] == target[2];
	};
	auto answer = check_tri(num_str[0..3]) || check_tri(num_str[1..4]) ? "Yes" : "No";
	writeln(answer);
}