count = 0 move = 0 with open("./input", "r") as f: for c in f.read(): move += 1 if c == '(': count = count + 1 elif c == ')': count = count - 1 if count == -1: break print(count) print(move)