from collections import Counter def double_string(st: str, n: int) -> int: if len(set(st)) == 1: # 代表字符串只由一个字符组成 return 0 return n - sorted(list(Counter(st).values()))[-1] while True: try: s = input().strip() n = len(s) s1 = s[0:n // 2] # 字符串的上半 s2 = s[n // 2:n] # 字符串的下半 print(double_string(s1, n // 2) + double_string(s2, n // 2)) except: break