import java.util.Scanner;
class twt
{
public static void main
(String args
[]) {
Scanner s
= new Scanner
(System.
in); int n,k,i,j,c,p;
n = s.nextInt();
k = s.nextInt();
i = k;
c = 0;
int a[] = new int[1002];
while(true)
{
i--;
x = s.next();
if(x.equals("CLOSEALL"))
{
c = 0;
for(p=0;p<n;p++)
a[p]=0;
}
else
{
y = s.next();
if(a[j]==0)
{
a[j]++;
c++;
}
else
{
a[j]--;
c--;
}
}
if(i==0)
break;
}
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwpjbGFzcyB0d3QKICAgIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZyBhcmdzW10pIAogICAgICAgIHsKICAgIFNjYW5uZXIgcyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICBpbnQgbixrLGksaixjLHA7CiAgICBTdHJpbmcgeCA7CiAgICBTdHJpbmcgeTsKCiAgICBuID0gcy5uZXh0SW50KCk7CiAgICBrID0gcy5uZXh0SW50KCk7CiAgICBpID0gazsKICAgIGMgPSAwOwogICAgaW50IGFbXSA9IG5ldyBpbnRbMTAwMl07CiAgICB3aGlsZSh0cnVlKQogICAgICAgIHsKCiAgICAgICAgaS0tOwogICAgICAgIHggPSBzLm5leHQoKTsKCiAgICAgICAgaWYoeC5lcXVhbHMoIkNMT1NFQUxMIikpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgYyA9IDA7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihjKTsKICAgICAgICAgICAgZm9yKHA9MDtwPG47cCsrKQogICAgICAgICAgICBhW3BdPTA7CiAgICAgICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHkgPSBzLm5leHQoKTsKICAgICAgICAgICAgICAgIGogPSBJbnRlZ2VyLnBhcnNlSW50KHkpOwogICAgICAgICAgICAgICAgaWYoYVtqXT09MCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGFbal0rKzsKICAgICAgICAgICAgICAgIGMrKzsKICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihjKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHsgICAKICAgICAgICAgICAgICAgIGFbal0tLTsKICAgICAgICAgICAgICAgIGMtLTsgICAgCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oYyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gICAKICAgICAgICBpZihpPT0wKQogICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICB9CiAgICB9