let n = read_int ()
let a = n / 1000
let b = n / 100 - a * 10
let c = n / 10 - a * 100 - b * 10
let d = n mod 10
let ans = if a = b && b = c || b = c && c = d then "Yes" else "No"
let () = print_endline ans