class init_dic(object):
    """docstring for init_dic."""
    def __init__(self):
        self.__al = []
    def add(self, x):
        if x in self.__al:
            self.__al.remove(x)
        else:
            self.__al.append(x)

    def kaibun(self):
        return len(self.__al) <= 1

    def out(self):
        print(self.__al)

s = input()
n = [0]
for i in range(len(s)):
    n.append(0)
    n[i] = n[i-1] + 1
    t = init_dic()
    t.add(s[i])
    for j in range(i-1, -1, -1):
        t.add(s[j])
        if n[j-1] + 1 < n[i] and t.kaibun():
            n[i] = n[j-1]+1
print(n[len(s) - 1])
