n = int(input()) a = str(n) b = sorted(a)[-1] c = a.index(b) print(len(a)-c-1)