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()
res = S[0]
ans = 0
for i in range(1,len(S)):
  if S[i] == res:
    ans += 1
    res = S[i]
  else:
    ans = 0
    res = S[i]
if ans == 3:
  print('Yes')
else:
  print('No')
S = input()
res = S[0]
ans = 1
for i in range(1,len(S)):
  if S[i] == res:
    ans += 1
    res = S[i]
    if ans == 3:
      print('Yes')
      exit()
  else:
    ans = 1
    res = S[i]

print('No')
