#include <iostream>
#include <set>

using namespace std;

int main (){
  int q,t,x;
  set<int> a;

  cin >> q;

  for (int i = 0; i < q; i++){
    cin >> t;
    cin >> x;
    if (t==0){
      a.insert(x);
      cout << a.size() << endl;
    }else if(t==1){
      cout << a.count(x) << endl;
    }else{
      a.erase(x);
    }
  }
  return 0;
}

