#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, m, n;
  cin >> h >> m >> n;
  int* id = new int[n];
  int* hash = new int[n];
  int* hsh = new int[h];
  int nc = 0;
  int res = 0;
  char z;
  int i, j, k, l;
  for (i = 0; i < h; i++) {
    hsh[i] = 0;
  }
  for (i = 0; i < n; i++) {
    cin >> z;
    if (z == '+') {
      cin >> id[nc] >> hash[nc];
      int chash = hash[nc];
      while (hsh[chash] == 1) {
        res++;
        chash = (chash + m) % h;
      }
      hsh[chash] = 1;
      hash[nc] = chash;
      nc++;
    } else {
      int cid;
      cin >> cid;
      for (j = 0; j < nc; j++) {
        if (id[j] == cid) {
          hsh[hash[j]] = 0;
          break;
        }
      }
    }
  }
  cout << res;
  return 0;
}
