s=input() lens=len(s) if s[1:] == "3"*(lens-1): print(lens-1) else: print(-1)