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