n = input() tf = n[0] == "1" if tf: for i in n[1:]: if i != "3": tf = False break if tf: print(len(n)-1) else: print(-1)