n = input() if len(n) > 1 and n[0] == "1" and n[1:].count("3") == len(n[1:]): print(len(n[1:])) else: print(-1)