#include <cstdio>

typedef unsigned long long ll; // Why unsigned? hash % maxh should be nonnegative.

const int mlen = (int)1e5 + 1;
const int maxh = (int)1e6 + 3; // prime number
const int P = (int)1e9 + 7; // prime number

ll ha[maxh];
int x, val[maxh];
char s[mlen];

int main()
{
  freopen("incrementator.in", "r", stdin);
  freopen("incrementator.out", "w", stdout);

  while (scanf("%s%d", s, &x) == 2)
  {
    ll hash = 13;
    for (int i = 0; s[i]; i++)
      hash = hash * P + s[i];

    int i = hash % maxh;
    while (ha[i] != hash && ha[i])
      if (++i == maxh)
        i = 0;

    ha[i] = hash, val[i] += x;
    printf("%d\n", val[i]);
  }
  return 0;
}