n=int(input()) t=str(n) for i in range(1,len(t)): if int(t[i])==3: continue else: print(-1) exit() print(len(t)-1)