#!/bin/python3
import sys
import threading
sys.setrecursionlimit(200200)
threading.stack_size(2**28)


s = input()
n = len(s)

def one(a, b, force, c):
    if b - a < 1:
         return 0
    if (c[2*a+force] != 0):
         return c[2*a+force] - 1
    if s[a] == s[b]:
        m = 0
    else:
        m = 1
    r = 1000000
    for i in range (0, 3):
        if (( (m == 0) & (force == 1) & (i == 0)) | ( (m == 1) & (force != 1) & (i == 0) )  | ( (m == 0) & (force == 0) & (i == 1)  )):
            continue
        if (i >= 1):
            r = min(r, i+one(a+1, b-1, 1, c))
        if (i != 1):
            r = min(r, i+one(a+1, b-1, 0, c))
    c[2*a+force] = 1 + r
    return r

c= [0]*(n+5)
print(one(0, n-1, 0, c))

