a = list(input()) b = [i for i in a if i == '1' or i == '3'] if (len(a) != len(b)) or len(a) == 1: print('-1') else: print(len(a))