#include <iostream>
#include <fstream>
using namespace std;
int V[1000];
// Declaring functions
void aggiungi(long long int id,int V[]) {
V[id]=V[id]+1;
}
void togli(long long int id,int V[]) {
V[id]=V[id]-1;
}
int conta(long long int id,int V[]) {
cout<<V[id]<<endl;
return 42;
}
int main() {
ios::sync_with_stdio(false);
// Uncomment the following lines if you want to read/write from files
// ifstream cin("input.txt");
// ofstream cout("output.txt");
int Q;
cin >> Q;
for(int i = 0; i < Q; i++){
char t;
long long int id;
cin >> t >> id;
if(t == 'a') {
aggiungi(id,V);
} else if (t == 't') {
togli(id,V);
} else if (t == 'c') {
cout << conta(id,V) << '\n';
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IFZbMTAwMF07Ci8vIERlY2xhcmluZyBmdW5jdGlvbnMKdm9pZCBhZ2dpdW5naShsb25nIGxvbmcgaW50IGlkLGludCBWW10pIHsKCVZbaWRdPVZbaWRdKzE7CiAgICAKfQoKdm9pZCB0b2dsaShsb25nIGxvbmcgaW50IGlkLGludCBWW10pIHsKCVZbaWRdPVZbaWRdLTE7CiAgICAKfQoKaW50IGNvbnRhKGxvbmcgbG9uZyBpbnQgaWQsaW50IFZbXSkgewoJY291dDw8VltpZF08PGVuZGw7CiAgICByZXR1cm4gNDI7Cn0KCmludCBtYWluKCkgewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwoKICAgIC8vIFVuY29tbWVudCB0aGUgZm9sbG93aW5nIGxpbmVzIGlmIHlvdSB3YW50IHRvIHJlYWQvd3JpdGUgZnJvbSBmaWxlcwogICAgLy8gaWZzdHJlYW0gY2luKCJpbnB1dC50eHQiKTsKICAgIC8vIG9mc3RyZWFtIGNvdXQoIm91dHB1dC50eHQiKTsKCiAgICBpbnQgUTsKICAgIGNpbiA+PiBROwoKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBROyBpKyspewogICAgICAgIGNoYXIgdDsKICAgICAgICBsb25nIGxvbmcgaW50IGlkOwogICAgICAgIGNpbiA+PiB0ID4+IGlkOwoKICAgICAgICBpZih0ID09ICdhJykgewogICAgICAgICAgICBhZ2dpdW5naShpZCxWKTsKICAgICAgICB9IGVsc2UgaWYgKHQgPT0gJ3QnKSB7CiAgICAgICAgICAgIHRvZ2xpKGlkLFYpOwogICAgICAgIH0gZWxzZSBpZiAodCA9PSAnYycpIHsKICAgICAgICAgICAgY291dCA8PCBjb250YShpZCxWKSA8PCAnXG4nOwogICAgICAgIH0KICAgIH0KCgoKICAgIHJldHVybiAwOwp9