n = input() a = n[1:] aset = set(a) if a[0] == "3" and len(aset) == 1: print(len(a)) else: print("-1")