#include <bits/stdc++.h>
using namespace std;
int main() {
	int q,t,x;
	cin >> q;
	set<int> set;
	for (int i = 0; i < q; ++i) {
		cin >> t >> x;
		switch (t) {
		case 0: set.insert(x);
			cout << set.size() << std::endl;
			break;
		case 1:
			cout << set.count(x) << std::endl;
			break;
		default:
			set.erase(x);
		}
	}
}
