N = input() ans = -1 l = len(N) if l >= 2 and N[0] == '1' and all(c == '3' for c in N[1:]): ans = l - 1 print(ans)