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