N = input() result = "13" in N and N[0] == "1" and len(list(set(N[1:]))) == 1 check=-1 if result: check=len(N[1:]) print(check)