fun main(args: Array<String>) {
	val n = readLine()!!.toInt();
	val a = n/1000;
	val b = (n%1000)/100;
	val c = (n%100)/10;
	val d = (n%10);

	println("${if ((a == b && b == c) || (b == c && c == d)) {"Yes"} else {"No"}}");
}

