# coding utf-8 s = input() if s[0] == "1" and set(s[1:]) == {"3"}: ans = len(s) - 1 print(ans) else: print(-1)