#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    set<int> s;
    int q, x, y;
  	cin >> q;
    for (int i = 0; i < q; i++){
        cin >> y >> x;
        if (y == 0) {
            s.insert(x);
            cout << s.size() << endl;
        }
        else if (y == 1){
            auto t = s.find(x);
            if (t != s.end()) cout << 1 << endl;
            else cout << 0 << endl;
        }
      	else s.erase(x);
        
    }
	return 0;
}
