s = input().rstrip() if len(set(s))>1: print(len(s)-2) elif len(s)%2==0: print(0) else: print(-1)