#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, m, n;
  cin >> h >> m >> n;
  vector<int> a(h, 0);
  map<int, int> p;
  long long ans = 0;
  char c;
  int id, hash;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == '+') {
      scanf("%i%i", &id, &hash);
      while (a[hash] != 0) {
        hash = (hash + m) % h;
        ans++;
      }
      a[hash] = 1;
      p[id] = hash;
    } else {
      scanf("%i", &id);
      a[p[id]] = 0;
    }
  }
  cout << ans;
  return 0;
}
