#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0, 0, 0, 0, 0};
int dy[] = {0, 0, 1, -1, 0, 0, 0, 0};
const long long inf = 100000007;
const double eps = 0.000000009;
long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long h, m, n;
  cin >> h >> m >> n;
  long long a[h];
  memset(a, -1, sizeof(a));
  map<long long, long long> p;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    char ch;
    cin >> ch;
    if (ch == '+') {
      long long t1, t2;
      cin >> t1 >> t2;
      while (a[t2] != -1) {
        ans++;
        t2 = (t2 + m) % h;
      }
      a[t2] = t1;
      p[t1] = t2;
    } else {
      long long t1;
      cin >> t1;
      long long x = p[t1];
      p.erase(t1);
      a[x] = -1;
    }
  }
  cout << ans << endl;
  return 0;
}
