import std.stdio;
import std.string;
import std.conv;

void main(){
auto a = readln.chomp.to!int;
auto b = a % 10;
auto c = a / 10 % 10;
auto d = a / 100 % 10;
auto e = a /1000 % 10;
writeln(b==c&&c==d||c==d&&d==e ? "Yes":"No");
}