import sys if __name__ == '__main__': n = list(input()) head = n[0] == "1" tail = n[1:] for x in tail: if x == "3": continue else: print(-1) sys.exit(0) print(len(tail))