#include <bits/stdc++.h>
using namespace std;

set<int> s;
unordered_map<int, bool> mp;

int main() {
    int q;
    cin >> q;

    while( q-- ) {  
        int op, key;
        cin >> op >> key;

        // insert into set
        if (op == 0) {
            s.insert(key);
            mp[key] = true;
            cout << s.size() << endl;
        } 
        
        // check existance
        else if ( op == 1 ) {
            if ( mp[key] ) cout << 1 << endl;
            else cout << 0 << endl;
        }

        else if (op == 2) {
            auto it = s.find( key );
            s.erase( key );
            mp[key] = false;
        }
    }

    return 0;
}

