#include<bits/stdc++.h>
using namespace std;
long long q, type, x, a = 0;
void input()
{
    cin >> q;
}
void solve()
{
    while(q--)
    {
        cin >> type;

        if(type == 1)
        {
            cin >> x;
            a ^= x;
        }
        else if(type == 2)
        {
            if(a != 0)
            {
                long long mask =1ll << (63 - __builtin_clzll(a));

                a ^= mask;
            }
        }
        else
        {
            cout << __builtin_popcountll(a) << '\n';
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    input();
    solve();
}

