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