Imports System
Public Class A100
    Public Shared Sub Main()
        Dim N As Integer
        N = Console.ReadLine()
        Dim a, b, c, d As Integer
        d = N Mod 10
        c = ((N - d) / 10) Mod 10
        b = ((N - d - 10 * c) / 100) Mod 10
        a = (N - d - 10 * c - 100 * b) / 1000
        If (a = b And b = c) Or (b = c And c = d) Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If
    End Sub
End Class
