#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll tree1[8000005], tree2[8000005];
int q[1000005];
int n = 2000000, m;
void build(int node, int tl, int tr) {
  if (tl == tr) {
    tree1[node] = 0;
    tree2[node] = 1;
    return;
  }
  int l = 2 * node, r = 2 * node + 1;
  int mid = (tl + tr) >> 1;
  build(l, tl, mid);
  build(r, mid + 1, tr);
  tree1[node] = 0;
  tree2[node] = tree2[l] + tree2[r];
}
void update(int node, int p, int v, int tl, int tr) {
  if (tl == p && tr == p) {
    tree1[node] = v;
    tree2[node] = 1;
    return;
  }
  int mid = (tl + tr) >> 1;
  int l = node * 2, r = node * 2 + 1;
  if (p <= mid) {
    update(l, p, v, tl, mid);
  } else {
    update(r, p, v, mid + 1, tr);
  }
  tree1[node] = tree1[r] + max((ll)0, tree1[l] - tree2[r]);
  tree2[node] = tree2[l] + max((ll)0, tree2[r] - tree1[l]);
}
pair<ll, ll> query(int node, int l, int r, int tl, int tr) {
  if (tl >= l && tr <= r) {
    return make_pair(tree1[node], tree2[node]);
  }
  int mid = (tl + tr) >> 1;
  auto lres = query(node * 2, l, r, tl, mid);
  if (r > mid) {
    auto rres = query(node * 2 + 1, l, r, mid + 1, tr);
    auto res = make_pair(rres.first + max((ll)0, lres.first - rres.second),
                         lres.second + max((ll)0, rres.second - lres.first));
    return res;
  } else {
    return lres;
  }
}
int main() {
  cin >> m;
  int s, d, j, t;
  char c;
  build(1, 1, 2000000);
  for (int i = 0; i < m; ++i) {
    cin >> c;
    if (c == '+') {
      cin >> s >> d;
      int e = s + d - 1;
      update(1, s, d, 1, n);
      q[i + 1] = s;
    } else if (c == '-') {
      cin >> j;
      update(1, q[j], 0, 1, n);
    } else {
      cin >> t;
      cout << query(1, 1, t, 1, n).first << endl;
    }
  }
  return 0;
}
