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**?
N = input()
flag = 0
if N[0] == N[1] and N[0] == N[2]:
  flag = 1
elif N[1] == N[2] and N[1] == N[3]:
  flag = 1
  
if flag == 1:
  print('YES')
else:
  print('NO')

N = input()
flag = 0
if N[0] == N[1] and N[0] == N[2]:
  flag = 1
elif N[1] == N[2] and N[1] == N[3]:
  flag = 1
  
if flag == 1:
  print('Yes')
else:
  print('No')
