from collections import defaultdict

def can_be_palindrome(s) :
    alpha = defaultdict(lambda: 0)
    for c in s :
        alpha[c] += 1

    flag = False
    for key in alpha.keys() :
        if alpha[key]%2 == 1 :
            if flag :
                return False
            flag = True
    else :
        return True

def main() :
    s = input()
    n = len(s)
    former = 0
    dp1 = [0]*n
    dp1[0] = 1
    for i in range(1, n) :
        if can_be_palindrome(s[0:i+1]) :
            former = i
            dp1[i] = 1
        elif can_be_palindrome(s[former+1:i+1]) :
            dp1[i] = 2
        else :
            dp1[i] = dp1[i-1]+1

    s = s[::-1]
    former = 0
    dp2 = [0]*n
    dp2[0] = 1
    for i in range(1, n) :
        if can_be_palindrome(s[0:i+1]) :
            dp2[i] = 1
        elif can_be_palindrome(s[former+1:i+1]) :
            dp2[i] = 2
        else :
            dp2[i] = dp2[i-1]+1
    print(min(dp1[n-1], dp2[n-1]))

main()