#include <iostream>
#include <vector>
#include <algorithm>
#include <set>


int main()
{
    int q,ope;
    long long num;
    std::cin>>q;
    std::set<long long> S;
    
    for(int i = 0; i < q; i++)
    {
        std::cin>>ope>>num;
        if(ope==1){std::cout<<S.count(num)<<std::endl;}
        else if(ope==0){S.insert(num);std::cout<<S.size()<<std::endl;}
        else{S.erase(num);}
    } 
    return 0;
}

