#include <bits/stdc++.h>
using namespace std;
int h, n, m;
long long x;
vector<long long> H;
int main() {
  cin >> h >> m >> n;
  H.resize(h, -1);
  int bad = 0;
  for (int i = 0; i < n; i++) {
    string op;
    cin >> op;
    if (op == "+") {
      int id;
      cin >> x >> id;
      int del = 0;
      while (H[(id + del) % h] != -1) {
        bad++;
        del = (del + m) % h;
      }
      H[(id + del) % h] = x;
    } else {
      int id;
      cin >> id;
      for (int i = 0; i < h; i++) {
        if (H[i] == id) {
          H[i] = -1;
        }
      }
    }
  }
  cout << bad << endl;
  return 0;
}
