s=input()
ans=0
k=0
k2=""
for i in range(len(s)-1):
    if s[i]!=s[i+1] :
        k1=s[k:i+1]
        if k1 !=k2:
            k2=k1
            ans+=1
    else:
        i=k
    
if ans==0:
    ans=1
elif ans==1:
    ans=2
else:
    ans=ans+2
print(ans)