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**?
import re

N = input()
cnt = 1
max = 0

for i in range(len(N)):
  if cnt > 1:
    cnt -= 1
    continue
  for j in range(i+1,len(N)):
    if N[i]==N[j]:
      cnt += 1
    else:
      break
    if max < cnt:
      max = cnt

if max > 3 and len(N)==4:
  print("Yes")
else:
  print("No")
import re

N = input()

def long_repeat(line):
 
    max = 0
    cnt = 1
    
    for i in range(len(line)-1):
        if cnt > 1:
            cnt -= 1
            continue
        for j in range(i+1,len(line)):
            if line[i] == line[j]:
                cnt += 1
            else:
                break
        if max < cnt:
            max = cnt
 
    return max

if long_repeat(N) >= 3 and len(N)==4:
  print("Yes")
else:
  print("No")