#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long INF_LL = 1000000000000000000LL;
class tree {
  int n;
  vector<int> t;

 public:
  tree(int n) : n(n), t(n) {}
  int len() { return n; }
  void inc(int i, int v) {
    for (; i < n; i |= i + 1) t[i] += v;
  }
  int sum(int r) {
    int res = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) res += t[r];
    return res;
  }
  int ye(int l, int r) {
    if (r > n) r = n;
    return (r - l) - (sum(r - 1) - sum(l - 1));
  }
};
const int h = 200022;
int n, m, k;
pair<int, int> u[h];
bool y[h];
vector<tree> t;
map<int, pair<int, int> > ui;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  memset(y, 0, sizeof y);
  for (int i(0), _b(n); i < _b; ++i)
    if (!y[i]) {
      int j = i;
      int k = 0;
      while (!y[j]) {
        y[j] = true;
        u[j] = pair<int, int>(int((t).size()), k);
        j += m;
        if (j >= n) j -= n;
        ++k;
      }
      t.push_back(tree(k));
    }
  long long ans = 0;
  char c;
  int id, hs;
  for (int i(0), _b(k); i < _b; ++i) {
    c = 0;
    while (c != '-' && c != '+') scanf("%c", &c);
    scanf("%d", &id);
    if (c == '+') {
      scanf("%d", &hs);
      int v = u[hs].first, p = u[hs].second;
      if (!t[v].ye(p, t[v].len())) {
        ans += t[v].len() - p;
        p = 0;
      }
      int a = 1;
      while ((a << 1) <= t[v].len()) a <<= 1;
      while (a > 0) {
        if (!t[v].ye(p, p + a)) {
          ans += a;
          p += a;
        }
        a >>= 1;
      }
      ui[id] = pair<int, int>(v, p);
      t[v].inc(p, 1);
    } else {
      pair<int, int> uid = ui[id];
      int v = uid.first, p = uid.second;
      t[v].inc(p, -1);
    }
  }
  cout << ans << endl;
  return 0;
}
