We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**.  You are given a 4-digit integer N. Answer the question: Is N **good**?
S = input()
cnt = 0
prev = S[0]
for c in S[1:]:
  if c == prev:
    cnt += 1
  else:
    cnt = 0
  if cnt > 2:
    print('Yes')
    exit()
  prev = c
print('No')
S = input()
cnt = 1
prev = S[0]
for c in S[1:]:
  if c == prev:
    cnt += 1
  else:
    cnt = 1
  if cnt > 2:
    print('Yes')
    exit()
  prev = c
print('No')