#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int LEN = 1e5;
char s[LEN + 1];
template <const int N>
struct HashTable {
ull h[N]; // 0 = empty
int f[N];
int & operator []( ull hash ) {
int i = hash % N;
while (h[i] && h[i] != hash)
i = (i + 1) % N;
if (!h[i])
h[i] = hash, f[i] = 0;
return f[i];
}
};
HashTable<(int)2e6 + 3> m;
int main() {
int x;
while (scanf("%s%d", s, &x) == 2) {
ull h = 13;
for (int i = 0; s[i]; i++)
h = h * 239017 + s[i];
printf("%d\n", m[h] += x);
}
}