from sys import stdin, stdout
n, k = map(int, stdin.readline().strip().split())
open_dict = dict()
open_tweets = 0
for i in range(k):
y = stdin.readline().strip()
# print(y)
if y=="CLOSEALL":
open_tweets = 0
for j in open_dict:
open_dict[j] = 0
else:
num = int(y[-1])
if num in open_dict:
if open_dict[num]==1:
open_dict[num]=0
open_tweets-=1
else:
open_tweets+=1
open_dict[num] = 1
else:
open_tweets+=1
open_dict[num] = 1
stdout.write(f"{open_tweets}\n")
If I do num = int(y.split()[1]) the code is getting accepted.
ProblemPROBLEM LINK