#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
 
int main(){
	ll q,c,x;
	cin >> q;
	set<ll> se;
	while(q--){
		cin >> c >> x;
		if(c==1){
			cout << se.count(x) << endl;
		}else if(c==0){
			se.insert(x);
			cout << se.size() << endl;
		}else if(c==2){
			se.erase(x);
		}
	}
}
