S = input()[1:] if len(S) != S.count("3") : print(-1) else : print(len(S))