n=input() if n[0]=='1' and len(set(n[1:])) == 1 and '3' in set(n[1:]): print(len(n[1:])) else: print(-1)