#include <bits/stdc++.h>
using namespace std;
int h, n, m, i;
struct item {
  int nxt;
  bool used;
} a[500000];
map<int, int> mp;
int main() {
  scanf("%d%d%d", &h, &m, &n);
  for (i = 0; i < h; i++) {
    a[i].nxt = i;
    a[i].used = false;
  }
  long long ans = 0;
  while (n--) {
    char ch[2];
    int num, val;
    scanf("%s%d", ch, &num);
    if (ch[0] == '+') {
      scanf("%d", &val);
      for (i = val;; i = (i + m) % h) {
        if (!a[i].used) {
          mp.insert(make_pair(num, i));
          a[i].used = true;
          break;
        }
        ans++;
      }
    } else {
      val = mp.find(num)->second;
      mp.erase(num);
      a[val].used = false;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
