#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(const auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename _Key> class ScapegoatTree {
private:
    struct node {
        const _Key key;
        unsigned int size;
        node *left, *right;
        node(const _Key& _key) : key(_key), size(1), left(nullptr), right(nullptr){}
        void eval(){
            size = 1;
            if(left) size += left->size;
            if(right) size += right->size;
        }
    };
    bool find(const node *cur, const _Key& key) const {
        while(cur){
            if(cur->key == key) return true;
            cur = (key < cur->key ? cur->left : cur->right);
        }
        return false;
    }
    void subtree_dfs(node *cur, vector<node*>& euler_tour) const {
        if(cur->left) subtree_dfs(cur->left, euler_tour);
        euler_tour.push_back(cur);
        if(cur->right) subtree_dfs(cur->right, euler_tour);
    }
    node *build_pbbt_rec(const int l, const int r, const vector<node*>& euler_tour){
        if(r - l == 0) return nullptr;
        else if(r - l == 1){
            node * const cur = euler_tour[l];
            cur->left = cur->right = nullptr;
            return cur->eval(), cur;
        }
        const int mid = (l + r) / 2;
        node * const cur = euler_tour[mid];
        cur->left = build_pbbt_rec(l, mid, euler_tour);
        cur->right = build_pbbt_rec(mid + 1, r, euler_tour);
        return cur->eval(), cur;
    }
    node *build_perfect_balanced_binary_tree(node *cur){
        if(!cur) return nullptr;
        vector<node*> euler_tour;
        subtree_dfs(cur, euler_tour);
        return build_pbbt_rec(0, (int)euler_tour.size(), euler_tour);
    }
    node *insert(node *cur, node *new_node, int depth, bool& balanced){
        if(!cur){
            balanced = (depth <= floor(log_val * log2(max_element_size)));
            return new_node;
        }else if(cur->key <= new_node->key){
            cur->right = insert(cur->right, new_node, depth + 1, balanced);
            cur->eval();
            if(balanced || cur->right->size <= alpha * cur->size) return cur;
        }else{
            cur->left = insert(cur->left, new_node, depth + 1, balanced);
            cur->eval();
            if(balanced || cur->left->size <= alpha * cur->size) return cur;
        }
        balanced = true;
        return build_perfect_balanced_binary_tree(cur);
    }
    node *join(node *left, node *right){
        if(!left || !right) return left ? left : right;
        else if(left->size < right->size){
            right->left = join(left, right->left);
            return right->eval(), right;
        }else{
            left->right = join(left->right, right);
            return left->eval(), left;
        }
    }
    void check(){
        if(size() >= alpha * max_element_size) return;
        root = build_perfect_balanced_binary_tree(root);
        max_element_size = size();
    }
    pair<node*, bool> erase(node *cur, const _Key& key){
        if(!cur) return {nullptr, false};
        else if(cur->key == key){
            node *res = join(cur->left, cur->right);
            delete cur;
            return {res, true};
        }else if(key < cur->key){
            pair<node*, bool> res = erase(cur->left, key);
            cur->left = res.first;
            return cur->eval(), make_pair(cur, res.second);
        }else{
            pair<node*, bool> res = erase(cur->right, key);
            cur->right = res.first;
            return cur->eval(), make_pair(cur, res.second);
        }
    }
    void clear(node *cur){
        if(cur->left) clear(cur->left);
        if(cur->right) clear(cur->right);
        delete cur;
    }
    node *root;
public:
    const double alpha, log_val;
    size_t max_element_size;
    ScapegoatTree(const double _alpha=2.0/3.0)
        : root(nullptr), alpha(_alpha), log_val(-1.0 / log2(alpha)), max_element_size(0){}
    // ~ScapegoatTree(){ if(root) clear(root); }
    bool empty() const { return !root; }
    size_t size() const { return empty() ? 0 : root->size; }
    bool find(const _Key& key) const { return find(root, key); }
    void insert(const _Key& key){
        max_element_size = max(max_element_size, size() + 1);
        bool balanced = true;
        root = insert(root, new node(key), 0, balanced);
        assert(balanced);
    }
    bool erase(const _Key& key){
        pair<node*, bool> res = erase(root, key);
        root = res.first, check();
        return res.second;
    }
};

#define getchar getchar_unlocked
#define putchar putchar_unlocked

inline int in() {
    int n = 0; short c;
    while ((c = getchar()) >= '0') n = n * 10 + c - '0';
    return n;
}

inline void out(int n) {
    short res[10], i = 0;
    do { res[i++] = n % 10, n /= 10; } while (n);
    while (i) putchar(res[--i] + '0');
    putchar('\n');
}

int main(){
    int n = in();
    ScapegoatTree<int> st;
    int u, v;
    rep(i,n){
        u = in(), v = in();
        if(u == 0){
            if(!st.find(v)) st.insert(v);
            out(st.size());
        }else if(u == 1){
            out(st.find(v));
        }else{
            st.erase(v);
        }
    }
    return 0;
}


Measured memory_bytes: 10384