defmodule Main do
  def main do
    s =
      IO.read(:line)
      |> String.trim
    a = String.slice(s, 0..2)
    b = String.slice(s, 1..3)
    if a == "000" or a == "111" or a == "222" or a == "333" or a == "444" or a == "555" or a == "666" or a == "777" or a == "888" or a == "999" or b == "000" or b == "111" or b == "222" or b == "333" or b == "444" or b == "555" or b == "666" or b == "777" or b == "888" or b == "999" do
      IO.puts("Yes")
    else
      IO.puts("No")
    end
  end
end
