#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<
tuple<int, int, int>,
null_type,
less<tuple<int, int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
int main()
{
int n;
scanf("%d", &n);
ordered_set me[2];
for(int i = 0; i < n; i++)
{
int a, t, x;
scanf("%d%d%d", &a, &t, &x);
if(a == 1)
me[0].insert(make_tuple(x, t, i));
else if(a == 2)
me[1].insert(make_tuple(x, t, i));
else
cout << me[0].order_of_key(make_tuple(x, t + 1, 0)) - me[0].order_of_key(make_tuple(x, 0, 0)) -
(me[1].order_of_key(make_tuple(x, t + 1, 0)) - me[1].order_of_key(make_tuple(x, 0, 0)))<< "\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxleHQvcGJfZHMvYXNzb2NfY29udGFpbmVyLmhwcD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIG5hbWVzcGFjZSBfX2dudV9wYmRzOwoKdHlwZWRlZiB0cmVlPAp0dXBsZTxpbnQsIGludCwgaW50PiwKbnVsbF90eXBlLApsZXNzPHR1cGxlPGludCwgaW50LCBpbnQ+PiwKcmJfdHJlZV90YWcsCnRyZWVfb3JkZXJfc3RhdGlzdGljc19ub2RlX3VwZGF0ZT4gb3JkZXJlZF9zZXQ7CgoKaW50IG1haW4oKQp7CglpbnQgbjsKCXNjYW5mKCIlZCIsICZuKTsKCW9yZGVyZWRfc2V0IG1lWzJdOwoJZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykKCXsKCQlpbnQgYSwgdCwgeDsKCQlzY2FuZigiJWQlZCVkIiwgJmEsICZ0LCAmeCk7CgkJaWYoYSA9PSAxKQoJCQltZVswXS5pbnNlcnQobWFrZV90dXBsZSh4LCB0LCBpKSk7CgkJZWxzZSBpZihhID09IDIpCgkJCW1lWzFdLmluc2VydChtYWtlX3R1cGxlKHgsIHQsIGkpKTsKCQllbHNlCgkJCWNvdXQgPDwgbWVbMF0ub3JkZXJfb2Zfa2V5KG1ha2VfdHVwbGUoeCwgdCArIDEsIDApKSAtIG1lWzBdLm9yZGVyX29mX2tleShtYWtlX3R1cGxlKHgsIDAsIDApKSAtCgkJCQkJKG1lWzFdLm9yZGVyX29mX2tleShtYWtlX3R1cGxlKHgsIHQgKyAxLCAwKSkgLSBtZVsxXS5vcmRlcl9vZl9rZXkobWFrZV90dXBsZSh4LCAwLCAwKSkpPDwgIlxuIjsKCX0KCXJldHVybiAwOwp9