import sys s = input() print(s[0]) if s == "1": print(-1) sys.exit() if s[0] == "1": for i in range(1, len(s)): if not s[i] == "3": print(-1) sys.exit() print((len(s) - 1)) else: print(-1) sys.exit()