N = input() if not (N[0] == "1" and set(N[1:]) == {"3"}): print(-1) else: print(len(N)-1)