/**
* Author: Sergey Kopeliovich (Burunduk30@gmail.com)
*/
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
unordered_map<int, long long> f;
const int M = 1e9 + 10;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
char c;
int x;
while (cin >> c >> x) {
if (c == '+') {
for (int i = x; i < M; i |= i + 1)
f[i] += x;
} else {
long long sum = 0;
for (int i = x; i >= 0; i &= i + 1, i--)
sum += f[i];
cout << sum << "\n";
}
}
return 0;
}