#include<iostream>
#include<set>
using namespace std;
int main(){
  
  int n,a,b;
  set<int> se;

  cin >> n;
  while(n--){
    cin >> a >> b;
    if(a == 0){
      se.insert(b);
      cout << se.size() << endl;
    }
    if(a == 1){
      if(se.find(b) != se.end()) cout << 1 << endl;
      else cout << 0 << endl;
    }
    if(a == 2){
      se.erase(b);
    }
  }
  
  return(0);
}

