#include<iostream>
#include<set>
using namespace std;
int main(){
	set<int>S;
	int q;
	cin>>q;
	while(q--){
		int c,x;
		cin>>c>>x;
		if(c==0){
			S.insert(x);
			cout<<S.size()<<endl;
		}
		else if(c==1){
			if(S.find(x)==S.end())
				cout<<0<<endl;
			else
				cout<<1<<endl;
		}
		else{
			S.erase(x);
		}
	}
	return 0;
}
