n = input() if len(n) == 1: print(-1) elif n[0] != "1": print(-1) else: s = set(n[1:]) if len(s) >= 2: print(-1) else: print(len(n[1:]))