n, k = map(int, input().split())
ans = []
for _ in range(k):
n = input()
if n == 'CLOSEALL':
ans = []
else:
if n[-1] not in ans:
ans.append(n[-1])
else:
ans.remove(n[-1])
print(len(ans))
link to problem: TWTCLOSE Problem - CodeChef