s = input() if s[0] == '1' and all(i == '3' for i in s[1:]): print(len(s) - 1) else: print(-1)