# include <iostream>
# include <set>
# include <string>
# include <cstdio>
using namespace std;
multiset<int> storage;
set<int> history;
void commandTranslator(string& s, int n)
{
if ( s == "add" )
{
storage.insert(n);
history.insert(n);
printf("%d\n",storage.count(n));
}
if ( s == "del" )
{
printf("%d\n",storage.erase(n));
}
if ( s == "ask" )
{
set<int>::iterator i;
i = history.find(n);
if ( i != history.end() )
{
printf("1 ");
printf("%d\n",storage.count(n));
}
else
{
printf("0 0\n");
}
}
}
int main()
{
int n = 0;
char input[100];
string inputCommand;
int inputNum = 0;
cin >> n;
for ( int i = 0; i < n; i++ )
{
scanf("%s%d",input,&inputNum);
inputCommand = input;
commandTranslator(inputCommand,inputNum);
}
return 0;
}