import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)

from collections import Counter, deque

#from collections import defaultdict

from itertools import combinations, permutations, accumulate, groupby, product

from bisect import bisect_left,bisect_right

from heapq import heapify, heappop, heappush

from math import floor, ceil,pi

#from operator import itemgetter

from copy import deepcopy

def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))

def LI2(): return [int(eval(input())) for i in range(n)]

def MXI(): return [LI()for i in range(n)]

inf = 10**17

mod = 10**9 + 7



s=input().rstrip()

u=list(s)

if (u[0]==u[1] and u[0]==u[2]) or (u[3]==u[1] and u[3]==u[2]):

    print("Yes")

else:

    print("No")
# coding: utf-8

# hello worldと表示する

# coding: utf-8

# hello worldと表示する

#float型を許すな

#numpyはpythonで

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)

from collections import Counter, deque

from collections import defaultdict

from itertools import combinations, permutations, accumulate, groupby, product

from bisect import bisect_left,bisect_right

from heapq import heapify, heappop, heappush

from math import floor, ceil,pi,factorial

from operator import itemgetter

def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))

def LI2(): return [int(eval(input())) for i in range(n)]

def MXI(): return [[LI()]for i in range(n)]

def SI(): return input().rstrip()

def printns(x): print(('\n'.join(x)))

def printni(x): print(('\n'.join(list(map(str,x)))))

inf = 10**17

mod = 10**9 + 7



s=SI()

if (s[0]==s[1] and s[1]==s[2]) or (s[1]==s[2] and s[2]==s[3]):

    print("Yes")

else:

    print("No")

    

    

    

    

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque

# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil, pi

# from operator import itemgetter
from copy import deepcopy


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def LI2():
    return [int(eval(input())) for i in range(n)]


def MXI():
    return [LI() for i in range(n)]


inf = 10**17
mod = 10**9 + 7
s = input().rstrip()
u = list(s)
if (u[0] == u[1] and u[0] == u[2]) or (u[3] == u[1] and u[3] == u[2]):
    print("Yes")
else:
    print("No")

# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
# float型を許すな
# numpyはpythonで
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil, pi, factorial
from operator import itemgetter


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def LI2():
    return [int(eval(input())) for i in range(n)]


def MXI():
    return [[LI()] for i in range(n)]


def SI():
    return input().rstrip()


def printns(x):
    print(("\n".join(x)))


def printni(x):
    print(("\n".join(list(map(str, x)))))


inf = 10**17
mod = 10**9 + 7
s = SI()
if (s[0] == s[1] and s[1] == s[2]) or (s[1] == s[2] and s[2] == s[3]):
    print("Yes")
else:
    print("No")

+# coding: utf-8 +# hello worldと表示する +# coding: utf-8 +# hello worldと表示する +# float型を許すな +# numpyはpythonで - -# from collections import defaultdict +from collections import defaultdict -from math import floor, ceil, pi - -# from operator import itemgetter -from copy import deepcopy +from math import floor, ceil, pi, factorial +from operator import itemgetter -    return [LI() for i in range(n)] +    return [[LI()] for i in range(n)] + + +def SI(): +    return input().rstrip() + + +def printns(x): +    print(("\n".join(x))) + + +def printni(x): +    print(("\n".join(list(map(str, x))))) -s = input().rstrip() -u = list(s) -if (u[0] == u[1] and u[0] == u[2]) or (u[3] == u[1] and u[3] == u[2]): +s = SI() +if (s[0] == s[1] and s[1] == s[2]) or (s[1] == s[2] and s[2] == s[3]):