#include <utility>
using namespace std;

template<class Key, class T>
struct splay_map {
  struct node {
    node* left;
    node* right;
    node* parent;
    Key key;
    T val;
    node(Key k, T v) : val(v), key(k), left(nullptr), right(nullptr), parent(nullptr){}
    ~node() {
      delete left , left = nullptr;
      delete right , right = nullptr;
    }
  };

  node* root;
  node* fix(node* n) {
    if(!n) return nullptr;
    return n;
  }
  void setl(node* par, node* x) {
    if(par) par->left = x;
    if(x) x->parent = par;
    fix(par);
  }
  void setr(node* par, node* x) {
    if(par) par->right = x;
    if(x) x->parent = par;
    fix(par);
  }
  void zig(node* x) {
    node* p = x->parent;
    setl(p, x->right);
    if(p->parent) {
      if(p->parent->left == p) setl(p->parent, x);
      else setr(p->parent, x);
    }
    else x->parent = nullptr;
    setr(x, p);
  }
  void zag(node* x) {
    node* p = x->parent;
    setr(p, x->left);
    if(p->parent) {
      if(p->parent->left == p) setl(p->parent, x);
      else setr(p->parent, x);
    }
    else x->parent = nullptr;
    setl(x, p);
  }
  void splay(node* x) {
    if(!x) return;
    while(x->parent) {
      if(!x->parent->parent){
        if(x->parent->left == x) zig(x);
        else zag(x);
      }
      else if(x->parent->parent->left == x->parent && x->parent->left == x){
        zig(x->parent);
        zig(x);
      }
      else if(x->parent->parent->left == x->parent && x->parent->right == x){
        zag(x);
        zig(x);
      }
      else if(x->parent->parent->right == x->parent && x->parent->right == x){
        zag(x->parent);
        zag(x);
      }
      else{
        zig(x);
        zag(x);
      }
    }
    root = x;
  }

  bool find(Key key) {
    node* z = root;
    node* p = nullptr;
    while(z) {
      p = z;
      if(z->key == key) {
        splay(z);
        return true;
      }
      else if(z->key < key) {
        z = z->right;
      }
      else {
        z = z->left;
      }
    }
    splay(p);
    return false;
  }
  void insert(Key key, T val) {
    if(find(key)) return;
    node* z = new node(key, val);
    if(root == nullptr)
      root = z;
    else if(root->key < key) {
      setr(z, root->right);
      setr(root,z);
    }
    else {
      setl(z, root->left);
      setl(root, z);
    }
    return splay(z);
  }
  void erase(Key key) {
    if(!find(key)) return;
    node* z = root;
    if(!z->left && !z->right)
      root = nullptr;
    else if(!z->left) {
      root = z->right;
      root->parent = nullptr;
    }
    else if(!z->right) {
      root = z->left;
      root->parent = nullptr;
    }
    else {
      node* lm = z->left;
      while(lm->right) {
        lm = lm->right;
      }
      z->left->parent = nullptr;
      splay(lm);
      root = lm;
      setr(root, z->right);
    }
  }

  splay_map() : root(nullptr) {}
  ~splay_map() { delete root; }
};

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  splay_map<int,int> mp;
  int q;
  cin >> q;
  int ans = 0;
  for(int i = 0;i < q;i++) {
    int c, x;
    cin >> c >> x;
    if(c == 0) {
      if(!mp.find(x)) {
        mp.insert(x,0);
        ans++;
      }
      cout << ans <<endl;
    }
    else if(c == 1) {
      cout << mp.find(x) << endl;
    }
    else {
      if(!mp.find(x)) continue;
      mp.erase(x);
      ans--;
    }
  }
}



Measured memory_bytes: 13460