#include <bits/stdc++.h>
using namespace std;

void compress(vector<int>& v) {
	auto vs = v;
	sort(vs.begin(), vs.end());
	vs.erase(unique(vs.begin(), vs.end()), vs.end());
	for (auto& val : v) {
		val = lower_bound(vs.begin(), vs.end(), val) - vs.begin();
	}
}

const int MAX = 2e5;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int q;
	cin >> q;
	vector<int> c(q), x(q);
	for (int i = 0; i < q; i++) {
		cin >> c[i] >> x[i];
	}
	compress(x);
	vector<int> cnt(MAX);
	int size = 0;
	for (int i = 0; i < q; i++) {
		if (c[i] == 0) {
			if (!cnt[x[i]]) {
				cnt[x[i]] = 1;
				++size;
			}
			printf("%d\n", size);
		}
		else if (c[i] == 1) {
			puts(cnt[x[i]] ? "1" : "0");
		}
		else {
			if (cnt[x[i]]) {
				cnt[x[i]] = 0;
				--size;
			}
		}
	}
	return 0;
}

