let () = Scanf.scanf "%d" (fun n ->
  Array.init 10 (( * ) 111)
  |> Array.to_list
  |> List.exists (fun m -> n mod 1000 = m || n / 10 = m)
  |> (function true -> "Yes" | false -> "No")
  |> print_endline)