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