def solve(): n = list(input()) if len(n) == 1: print(-1) return for i, x in enumerate(n): if i == 0 and x != "1": print(-1) return if i > 0 and x != "3": print(-1) return print(len(n)-1) solve()