#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
struct node
{
int key;
int prior;
int cnt;
node * l, * r;
node(){}
node (int _key) : key(_key), prior(rand()), cnt(1), l(0), r(0){}
};
int cnt(node * v)
{
return v ? v->cnt : 0;
}
void upd(node * v)
{
if (v) v->cnt = 1 + cnt(v->l) + cnt (v->r);
}
void split (node * v, int key, node * & l, node * & r) {
if (!v) l = r = 0;
else if (key < v->key)
split (v->l, key, l, v->l), r = v;
else
split (v->r, key, v->r, r), l = v;
upd(v);
}
void insert (node * & v, node * add) {
if (!v) v = add;
else if (add->prior > v->prior)
split (v, add->key, add->l, add->r), v = add;
else
insert (add->key < v->key ? v->l : v->r, add);
upd(v);
}
int get(node * v, int val)
{
if (!v) return 0;
if (val == v->key) return 1 + cnt(v->r);
if (val < v->key)
return cnt(v->r) + 1 + get(v->l, val);
else
return get(v->r, val);
}
node ** BIT;
int s;
int get(int r, int val)
{
int res = 0;
for(; r >= 0; r = (r & (r + 1)) - 1)
res += get(BIT[r], val);
return res;
}
void add(int pos, int val)
{
for(; pos < s; pos |= pos + 1)
{
node * add = new node(val);
insert(BIT[pos], add);
}
}
int main()
{
int n;
scanf("%d", &n);
getchar();
int l[n], r[n], type[n];
char c;
for(int i = 0; i < n; ++i)
{
c = getchar();
scanf("%d %d", l + i, r + i);
getchar();
type[i] = (c == '+') ? 0 : 1;
}
int z[n];
memcpy(z, l, sizeof(l));
sort(z, z + n);
s = unique(z, z + n) - z;
BIT = new node* [s];
for(int i = 0; i < n; ++i)
{
l[i] = lower_bound(z, z + s, l[i]) - z;
if (type[i])
printf("%d\n", get(l[i], r[i]));
else
add(l[i], r[i]);
}
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjc3RyaW5nPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBub2RlCnsKICA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1cm4gZ2V0KHYtPnIsIHZhbCk7Cn0KCm5vZGUgKiogQklUOwppbnQgczsKCmludCBnZXQoaW50IHIsIGludCB2YWwpCnsKICAgIGludCByZXMgPSAwOwogICAgZm9yKDsgciA+PSAwOyByID0gKHIgJiAociArIDEpKSAtIDEpCiAgICAgICAgcmVzICs9IGdldChCSVRbcl0sIHZhbCk7CiAgICByZXR1cm4gcmVzOwp9Cgp2b2lkIGFkZChpbnQgcG9zLCBpbnQgdmFsKQp7CiAgICBmb3IoOyBwb3MgPCBzOyBwb3MgfD0gcG9zICsgMSkKICAgIHsKICAgICAgICBub2RlICogYWRkID0gbmV3IG5vZGUodmFsKTsKICAgICAgICBpbnNlcnQoQklUW3Bvc10sIGFkZCk7CiAgICB9Cn0KCmludCBtYWluKCkKewogICAgaW50IG47CiAgICBzY2FuZigiJWQiLCAmbik7CiAgICBnZXRjaGFyKCk7CiAgICBpbnQgbFtuXSwgcltuXSwgdHlwZVtuXTsKICAgIGNoYXIgYzsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyArK2kpCiAgICB7CiAgICAgICAgYyA9IGdldGNoYXIoKTsKICAgICAgICBzY2FuZigiJWQgJWQiLCBsICsgaSwgciArIGkpOwogICAgICAgIGdldGNoYXIoKTsKICAgICAgICB0eXBlW2ldID0gKGMgPT0gJysnKSA/IDAgOiAxOwogICAgfQogICAgaW50IHpbbl07CiAgICBtZW1jcHkoeiwgbCwgc2l6ZW9mKGwpKTsKICAgIHNvcnQoeiwgeiArIG4pOwogICAgcyA9IHVuaXF1ZSh6LCB6ICsgbikgLSB6OwogICAgQklUID0gbmV3IG5vZGUqIFtzXTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyArK2kpCiAgICB7CiAgICAgICAgbFtpXSA9IGxvd2VyX2JvdW5kKHosIHogKyBzLCBsW2ldKSAtIHo7CiAgICAgICAgaWYgKHR5cGVbaV0pCiAgICAgICAgICAgIHByaW50ZigiJWRcbiIsIGdldChsW2ldLCByW2ldKSk7CiAgICAgICAgZWxzZQogICAgICAgICAgICBhZGQobFtpXSwgcltpXSk7CiAgICB9CiAgICByZXR1cm4gMDsKfQoK