#include <bits/stdc++.h>
using namespace std;
const int N = 210000;
const double eps = 1e-9;
const int oo = 1000000000;
int n, m, q, t, v, c[N], d[N], f[N];
bool flag[N];
map<int, int> loc;
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
void build() {
  t = 1;
  v = gcd(n, m);
  for (int i = 0; i < v; ++i) {
    for (int j = i;; j = (j + m) % n) {
      c[j] = t;
      t++;
      if ((j + m) % n == i) {
        break;
      }
    }
  }
  loc.clear();
  memset(f, 0, sizeof(f));
}
int query(int x) {
  int ret = 0;
  for (; x; x -= (x & -x)) {
    ret += f[x];
  }
  return ret;
}
void update(int x, int d) {
  for (; x < N; x += (x & -x)) {
    f[x] += d;
  }
}
int part(int x, int y) {
  int u = query(x - 1), xx = x - 1;
  while (x < y) {
    int M = (x + y) >> 1;
    if (query(M) - u == M - xx) {
      x = M + 1;
    } else {
      y = M;
    }
  }
  return x;
}
void solve() {
  long long ans = 0;
  while (q--) {
    char cmd[5];
    int id, x;
    scanf("%s%d", cmd, &id);
    if (cmd[0] == '+') {
      scanf("%d", &x);
      int o = c[x];
      int l = (o - 1) / (n / v) * (n / v) + 1;
      int r = ((o - 1) / (n / v) + 1) * (n / v);
      int y;
      if (query(r) - query(o - 1) != r - o + 1) {
        y = part(o, r);
        ans += y - o;
        loc[id] = y;
      } else {
        y = part(l, o - 1);
        ans += r - o + (part(l, o - 1) - l) + 1;
        loc[id] = y;
      }
      update(y, 1);
    } else {
      x = loc[id];
      update(x, -1);
    }
  }
  cout << ans << endl;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  build();
  solve();
  return 0;
}
