#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-10;
int in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
int table[300000];
void solve() {
  int h = in();
  int m = in();
  int n = in();
  memset(table, 0, sizeof table);
  int i, j;
  int id, hash;
  char c;
  long long dum = 0;
  for (i = 0; i < n; i++) {
    cin >> c;
    if (c == '+') {
      id = in() + 1;
      hash = in();
      while (table[hash] != 0) {
        dum++;
        hash = (hash + m) % h;
      }
      table[hash] = id;
    } else {
      id = in() + 1;
      for (j = 0; j < h; j++)
        if (table[j] == id) table[j] = 0;
    }
  }
  cout << dum << endl;
}
int main() {
  solve();
  return 0;
}
