#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, m, n;
  cin >> h >> m >> n;
  vector<int> v(h, -1);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    char c;
    int id, hash;
    cin >> c;
    if (c == '+') {
      cin >> id >> hash;
      while (v[hash] != -1) {
        hash = (hash + m) % h;
        ++ans;
      }
      v[hash] = id;
    } else {
      cin >> id;
      for (int i = 0; i < h; ++i)
        if (v[i] == id) {
          v[i] = -1;
          break;
        }
    }
  }
  cout << ans << endl;
}
