open Batteries
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in

  let rec digits base n res =
    if n = 0 then res 
    else digits base (n/base) ((n mod base)::res)
  in

  let digits_l = digits 10 n [] in

  let rec aux prev cnt = function
      [] -> "No" 
    | hd :: tl -> 
      if prev = hd then
        let cnt = cnt + 1 in
        if cnt = 3 then
          "Yes"
        else
          aux hd (cnt+1) tl
      else 
        aux hd 0 tl
  in

  Printf.printf "%s\n" @@
  aux (-1) 0 digits_l
