#include <bits/stdc++.h>
using namespace std;
const int maxn = 5555;
int h, m, n;
bool used[maxn];
map<int, int> mii;
int main() {
  scanf("%d %d %d", &h, &m, &n);
  memset(used, false, sizeof(used));
  mii.clear();
  char op;
  int id, hashVal;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("\n%c %d", &op, &id);
    if (op == '+') {
      scanf("%d", &hashVal);
      for (int i = 0; i < h; ++i) {
        if (!used[(hashVal + i * m) % h]) {
          mii[id] = (hashVal + i * m) % h;
          used[(hashVal + i * m) % h] = true;
          break;
        } else
          ans++;
      }
    } else {
      used[mii[id]] = false;
    }
  }
  printf("%d\n", ans);
  return 0;
}
