#include <bits/stdc++.h>
using namespace std;
map<int, int> Map;
pair<int, int> a[250001];
vector<int> b[250001], t[250001];
char type;
long long ans;
int len[250001], n, m, i, q, l, r, d, mid, nom, nomN, zn, sum;
bool pole[250001];
int get(int tl, int tr, int nom, int l, int r, int nomT) {
  if (tl > tr) return 0;
  if (tl > r || tr < l) return 0;
  if (l <= tl && tr <= r) return t[nomT][nom];
  int mid = (tl + tr) / 2;
  return get(tl, mid, nom * 2, l, r, nomT) +
         get(mid + 1, tr, nom * 2 + 1, l, r, nomT);
}
void update(int tl, int tr, int nom, int nomN, int zn, int nomT) {
  if (tl > tr) return;
  if (tl > nomN || tr < nomN) return;
  t[nomT][nom] += zn;
  if (tl == tr) return;
  int mid = (tl + tr) / 2;
  update(tl, mid, nom * 2, nomN, zn, nomT);
  update(mid + 1, tr, nom * 2 + 1, nomN, zn, nomT);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> q;
  for (i = 0; i < n; i++)
    if (!pole[i]) {
      nom = i;
      d++;
      t[d].push_back(0);
      b[d].push_back(0);
      while (!pole[nom]) {
        pole[nom] = true;
        len[d]++;
        a[nom + 1] = make_pair(d, len[d]);
        b[d].push_back(nom);
        t[d].push_back(0);
        t[d].push_back(0);
        t[d].push_back(0);
        t[d].push_back(0);
        nom = (nom + m) % n;
      }
    }
  while (q--) {
    cin >> type;
    if (type == '+') {
      cin >> zn >> nom;
      nom++;
      sum = 0;
      if (get(1, len[a[nom].first], 1, a[nom].second, len[a[nom].first],
              a[nom].first) != len[a[nom].first] - a[nom].second + 1) {
        l = a[nom].second;
        r = len[a[nom].first];
        while (l <= r) {
          mid = (l + r) / 2;
          if (get(1, len[a[nom].first], 1, a[nom].second, mid, a[nom].first) !=
              mid - a[nom].second + 1) {
            r = mid - 1;
            sum = mid - a[nom].second;
          } else
            l = mid + 1;
        }
        update(1, len[a[nom].first], 1, a[nom].second + sum, 1, a[nom].first);
        Map[zn] = b[a[nom].first][a[nom].second + sum] + 1;
      } else {
        ans += len[a[nom].first] - a[nom].second + 1;
        l = 1;
        r = a[nom].second - 1;
        while (l <= r) {
          mid = (l + r) / 2;
          if (get(1, len[a[nom].first], 1, 1, mid, a[nom].first) != mid) {
            r = mid - 1;
            sum = mid - 1;
          } else
            l = mid + 1;
        }
        update(1, len[a[nom].first], 1, sum + 1, 1, a[nom].first);
        Map[zn] = b[a[nom].first][sum + 1] + 1;
      }
      ans += sum;
    } else {
      cin >> zn;
      nom = Map[zn];
      update(1, len[a[nom].first], 1, a[nom].second, -1, a[nom].first);
    }
  }
  cout << ans << '\n';
  return 0;
}
