#include <bits/stdc++.h>
using namespace std;
map<int, int> mm;
int vis[5010];
int main() {
  memset(vis, -1, sizeof(vis));
  int n, m, h, id, pos;
  char str[5];
  scanf("%d%d%d", &h, &m, &n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s%d", str, &id);
    if (str[0] == '+') {
      scanf("%d", &pos);
      if (vis[pos] == -1) {
        vis[pos] = id;
        mm[id] = pos;
      } else {
        int ti = 0;
        while (vis[(pos + ti * m) % h] != -1) {
          ans++;
          ti++;
        }
        vis[(pos + ti * m) % h] = id;
        mm[id] = (pos + ti * m) % h;
      }
    } else {
      vis[mm[id]] = -1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
