#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int h, m, n;
long long ret;
map<int, int> pos;
int table[200001];
void add(int id, int t) {
  while (table[t] != -1) {
    t += m;
    if (t >= h) t -= h;
    ret++;
  }
  table[t] = id;
  pos[id] = t;
}
void del(int id) {
  int p = pos[id];
  if (table[p] != id) throw 1;
  table[p] = -1;
}
void solution() {
  scanf("%d %d %d\n", &h, &m, &n);
  memset((table), (-1), sizeof((table)));
  for (int i = 0, _n = (n); i < _n; ++i) {
    char op;
    scanf("%c", &op);
    if (op == '+') {
      int id, t;
      scanf("%d %d\n", &id, &t);
      add(id, t);
    } else if (op == '-') {
      int id;
      scanf("%d\n", &id);
      del(id);
    } else
      throw 1;
  }
  cout << ret << endl;
}
int main() {
  solution();
  return 0;
}
