s = input()

n = len(s)
 
counter = 0
ans = n
 
for i in range(n-1):
  if s[i] == s[i+1]:
    counter += 1
    
if n > 2:
  ans = min(n-counter+1, n)
  print(ans)
  
elif n == 2:
  print( n - counter)