#include <bits/stdc++.h>
using namespace std;
int h[200500];
int n, m, t, d, e;
int a(int d, int s, int &m) {
  int ans = 0;
  for (int i = s;;) {
    if (h[i] == 0) {
      h[i] = d;
      break;
    } else
      ans++;
    i = (i + m) % n;
  }
  return ans;
}
int main() {
  memset(h, 0, sizeof h);
  cin >> n >> m >> t;
  char c;
  int ans = 0;
  while (t--) {
    cin >> c >> d;
    if (c == '+') {
      cin >> e;
      ans += a(d, e, m);
    } else if (c == '-') {
      for (int i = 0; i < n; i++)
        if (h[i] == d) {
          h[i] = 0;
          break;
        }
    }
  }
  cout << ans << endl;
  return 0;
}
