S = raw_input() ans = -1 for i in range(0, len(S)): if i == 0: if S[0] != '1': break else: if S[i] != '3': ans = -1 break ans += 1 print ans