S=input()
i=0
p="NO"
while i<len(S)-3 and p=="NO":
    if S[i]==S[i+1] and S[i+1]==S[i+2]:
        p="YES"
    i+=1
print(p)