a = input() if a[0] =="1" and a.count("3")==len(a)-1: print(len(a)-1) else: print(-1)