import os
import string
import sys
from collections import Counter
from functools import lru_cache

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


S = sys.stdin.buffer.readline().decode().rstrip()
N = len(S)

lefts = [{c: 0 for c in string.ascii_lowercase} for _ in range(N)]
rights = [{c: 0 for c in string.ascii_lowercase} for _ in range(N)]
for i in range(1, N):
    for c in string.ascii_lowercase:
        lefts[i][c] = lefts[i - 1][c]
    lefts[i][S[i - 1]] += 1
for i in reversed(range(N - 1)):
    for c in string.ascii_lowercase:
        rights[i][c] = rights[i + 1][c]
    rights[i][S[i + 1]] += 1
total = Counter(S)


def dump(counter):
    for c in sorted(counter.keys()):
        if counter[c] > 0:
            print(c, counter[c])
    print()


@lru_cache(maxsize=None)
def count_palindrome(l, r):
    if r <= l:
        assert False
    if l + 1 == r:
        return 1
    counts = total.copy()
    for c in string.ascii_lowercase:
        counts[c] -= lefts[l][c]
        counts[c] -= rights[r - 1][c]
    odds = 0
    for c in counts.values():
        odds += c % 2
    if odds <= 1:
        return 1

    ret = INF
    for i in range(l + 1, r):
        # i で split するときの両側の数
        cnt = count_palindrome(l, i) + count_palindrome(i, r)
        ret = min(cnt, ret)
    return ret


ans = count_palindrome(0, N)
print(ans)
