#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

map<int,int> fen[100001];

int type[100001];
int t[100001];
int x[100001];
pbds times;

const int N = 100001;

void add(int idx ,int val){
    while (idx <= N){
        fen[idx][val]++;
        idx += (idx & -idx);
    }
}

void remove(int idx ,int val){
    while (idx <= N){
        fen[idx][val]--;
        idx += (idx & -idx);
    }
}

int read(int idx, int val){
    int sum = 0;
    while (idx > 0){
        sum += fen[idx][val];
        idx -= (idx & -idx);
    }
    return sum;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; 
	cin >> n;
	int a, b, c;
	for(int i = 0; i < n; i++)
	{
		cin >> a >> b >> c;
		type[i] = a;
		t[i] = b;
		x[i] = c;
		times.insert(b);
	}
	for(int i = 0; i < n; i++)
	{
		a = type[i];
		b = times.order_of_key(t[i])+1;
		c = x[i];
		if(a == 1) add(b, c);
		if(a == 2) remove(b, c);
		if(a == 3) cout << read(b, c) << '\n';
	}
	return 0;
}