# Hash using polynomials over P mod M P, M = 31, 1000000009 def to_int(c): return ord(c) - ord('0') S = input() # We maintain a hash of characters on the left and right lh, rh, re = 0, 0, 1 # Scan inward from both sides and discard prefix-suffix pairs # with equal hashes l, r, ans = 0, len(S)-1, 0 while l < r: lh = (lh * P + to_int(S[l])) % M rh = (rh + re * to_int(S[r])) % M re = re * P % M l, r = l+1, r-1 if lh == rh: ans += 2 lh, rh, re = 0, 0, 1 if l == r or lh != 0 or rh != 0: ans += 1 print(ans)