s = list(input())
cnt = 0

def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())
c = counter(s)

try:
    cnt = min(c[0][1],c[1][1])
except:
    pass
print(cnt)

