#include <bits/stdc++.h>
long long dummy = 0;
int h, m, n, i;
int *hash;
void insertHash(int id, int t) {
  if (hash[t] != 0) {
    ++dummy;
    insertHash(id, (t + m) % h);
  } else
    hash[t] = id;
}
int main() {
  int id, t;
  scanf("%d%d%d", &h, &m, &n);
  hash = (int *)malloc(h * sizeof(int));
  for (i = 0; i < h; ++i) hash[i] = 0;
  while (n--) {
    char cmd[2];
    scanf("%s", cmd);
    if (cmd[0] == '+') {
      scanf("%d%d", &id, &t);
      insertHash(id, t);
    }
    if (cmd[0] == '-') {
      scanf("%d", &id);
      for (i = 0; i < h; ++i)
        if (hash[i] == id) {
          hash[i] = 0;
          break;
        }
    }
  }
  printf("%I64d\n", dummy);
  return 0;
}
