#include <iostream>
#include <memory>
#include <random>
#include <limits>
#include <ctime>

template <class Key>
class Treap {
    struct Node {
        bool isvalid;  // falseなら空Node
        Key key;
        int priority;

        int sz;
        Key sum;

        std::unique_ptr<Node> lch, rch;
        Node() : isvalid(false), sz(0), sum(0) {}
        Node(Key key, int priority)
            : isvalid(true), key(key), priority(priority), sz(1), sum(key), lch(new Node()), rch(new Node()) {}
    };
    using pNode = std::unique_ptr<Node>;

private:
    pNode root;

    // 乱数生成
    std::mt19937 mt;
    std::uniform_int_distribution<> rnd;

    int count(pNode& node) { return node->sz; }
    Key sum(pNode& node) { return node->key; }

    pNode& update(pNode& node) {
        node->sz = count(node->lch) + count(node->rch) + 1;
        node->sum = sum(node->lch) + sum(node->rch) + node->key;
        return node;
    }

    pNode& rotateR(pNode& node) {
        pNode lnode = std::move(node->lch);
        node->lch = std::move(lnode->rch);
        update(node);
        lnode->rch = std::move(node);
        update(lnode);
        return node = std::move(lnode);
    }

    pNode& rotateL(pNode& node) {
        pNode rnode = std::move(node->rch);
        node->rch = std::move(rnode->lch);
        update(node);
        rnode->lch = std::move(node);
        update(rnode);
        return node = std::move(rnode);
    }

    pNode& insert(Key key, int priority, pNode& node) {
        if (!node->isvalid) {
            node.reset(new Node(key, priority));
            return node;
        }

        if (node->key == key) return node;

        if (key < node->key) {
            node->lch = std::move(insert(key, priority, node->lch));
            update(node);
            return (node->priority < node->lch->priority ? rotateR(node) : node);
        } else {
            node->rch = std::move(insert(key, priority, node->rch));
            update(node);
            return (node->priority < node->rch->priority ? rotateL(node) : node);
        }
    }

    bool find(Key key, pNode& node) {
        if (!node->isvalid) return false;
        if (key == node->key) return true;
        return find(key, (key < node->key ? node->lch : node->rch));
    }

    // 削除対象を見つける
    pNode& erase(Key key, pNode& node) {
        if (!node->isvalid) return node;

        if (key == node->key) {
            return match_erase(key, node);
        } else {
            if (key < node->key) {
                node->lch = std::move(erase(key, node->lch));
            } else {
                node->rch = std::move(erase(key, node->rch));
            }
            return update(node);
        }
    }

    // 見つけた削除対象を消す
    pNode& match_erase(Key key, pNode& node) {
        if (!node->lch->isvalid && !node->rch->isvalid) {
            node.reset(new Node());
            return node;
        }

        if (!node->lch->isvalid) {
            return erase(key, rotateL(node));
        } else if (!node->rch->isvalid) {
            return erase(key, rotateR(node));
        } else {
            if (node->lch->priority > node->rch->priority) {
                return erase(key, rotateR(node));
            } else {
                return erase(key, rotateL(node));
            }
        }
    }

public:
    explicit Treap() : root(new Node()), mt(int(std::time(nullptr))), rnd(0, std::numeric_limits<int>::max()) {}

    void insert(Key key) { insert(key, rnd(mt), root); }
    bool find(Key key) { return find(key, root); }
    void erase(Key key) { erase(key, root); }
    int getsize() { return root->sz; }
    int getsum() { return root->sum; }
};

int main() {
    Treap<int> s;
    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int t, x;
        std::cin >> t >> x;
        if (t == 0) {
            s.insert(x);
            std::cout << s.getsize() << std::endl;
        } else if (t == 1) {
            std::cout << s.find(x) << std::endl;
        } else {
            s.erase(x);
        }
    }
}


Measured memory_bytes: 21880