# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1239417 | woe | Infinite Race (EGOI24_infiniterace2) | Pypy 3 | 0 ms | 0 KiB |
7n = int(input())
e = int(input())
lap = 0
ahead = set()
for _ in range(e):
x = int(input())
if x > 0:
if x in ahead:
lap += 1
ahead.clear()
ahead.add(x)
else:
ahead.discard(-x)
print(lap)