#include <bits/stdc++.h>
using namespace std;
struct tree {
  int sz;
  int real_sz;
  vector<int> v;
  vector<int> nod;
};
tree _tr[200005];
int tree_index[200005];
int tree_pos[200005];
map<int, pair<int, int> > mp;
int add_hash(int id, int hash) {
  tree *tr = &_tr[tree_index[hash]];
  int pos = tree_pos[hash];
  int sz = tr->sz;
  int i = sz + pos;
  int res = 0;
  int cur_q = 1;
  if (tr->nod[i]) {
    res++;
    while (i > 1) {
      if (i & 1) {
        i >>= 1;
        cur_q <<= 1;
      } else {
        i++;
        if (tr->nod[i] < cur_q) break;
        res += cur_q;
      }
    }
    if (i == 1) res -= sz - tr->real_sz;
    while (i < sz) {
      cur_q >>= 1;
      if (tr->nod[i << 1] < cur_q)
        i <<= 1;
      else {
        res += cur_q;
        i = (i << 1) + 1;
      }
    }
  }
  mp[id] = make_pair(tree_index[hash], i - sz);
  while (i > 0) {
    tr->nod[i]++;
    i >>= 1;
  }
  return res;
}
void delete_hash(int id) {
  pair<int, int> pr = mp[id];
  tree *tr = &_tr[pr.first];
  int pos = pr.second;
  int sz = tr->sz;
  int i = sz + pos;
  while (i > 0) {
    tr->nod[i]--;
    i >>= 1;
  }
}
int main() {
  memset(tree_index, -1, sizeof(tree_index));
  int h, m, n;
  scanf("%d%d%d", &h, &m, &n);
  int i;
  for (i = 0; i < h; i++) {
    int j = i;
    while (tree_index[j] == -1) {
      tree_index[j] = i;
      tree_pos[j] = _tr[i].v.size();
      _tr[i].v.push_back(j);
      j = (j + m) % h;
    }
  }
  for (i = 0; i < h; i++) {
    if (_tr[i].v.empty()) {
      continue;
    }
    int sz = _tr[i].v.size();
    int t = 1;
    while (t < sz) t <<= 1;
    _tr[i].sz = t;
    _tr[i].real_sz = sz;
    _tr[i].nod.resize((t << 1) + 3);
    int j;
    for (j = 1; j < (t << 1); j++) {
      _tr[i].nod[j] = 0;
    }
    for (j = t + _tr[i].real_sz; j < (t << 1); j++) {
      _tr[i].nod[j] = 1;
    }
    for (j = t - 1; j > 0; j--) {
      _tr[i].nod[j] = _tr[i].nod[j << 1] + _tr[i].nod[(j << 1) + 1];
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    char c[3];
    int ind;
    int hash;
    scanf("%s%d", c, &ind);
    if (c[0] == '+') {
      scanf("%d", &hash);
      ans += add_hash(ind, hash);
    } else {
      delete_hash(ind);
    }
  }
  cout << ans << endl;
  return 0;
}
