#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int n;
int main() {
scanf("%d", &n);
while (n--) {
char op; string s;
cin >> op >> s;
if (op == 'I') mp[s]++;
else cout << mp[s] << endl;
}
return 0;
}
大佬解释一下呗