S = input() if S != '1' and S[0] == '1' and all([c == '3' for c in S[1:]]): print(len(S) - 1) else: print(-1)