import sys input=lambda: sys.stdin.readline().rstrip() n=input() if len(n)>1 and n=="1"+"3"*(len(n)-1): print(len(n)-1) else: print(-1)