n = list(str(input())) for i in range(1,len(n)): if n[0] == "1" and n[i] == "3": print(len(n)-1) break else: print(-1)