import Glibc
extension String: CollectionType {}

//var abc = readLine()!.split(" ").map { Int($0)! }
var n = Int(readLine()!)!
var a = n / 1000
var b = (n % 1000) / 100
var c = (n % 100) / 10
var d = n % 10
if (a == b && b == c) || (b == c && c == d) {
  print("Yes")
} else {
  print("No")
}