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