#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T myabs(T x) {
  return (x > 0 ? x : -x);
}
template <class T>
string tostring(T x) {
  ostringstream q;
  q << x;
  return q.str();
}
int strtoint(string x) {
  istringstream q(x);
  int res;
  q >> res;
  return res;
}
const int INF = 0x7FFFFFFF;
int h, m, n;
map<int, int> mp;
bool debug = false;
int a[1111111];
int main() {
  cin >> h >> m >> n;
  int res = 0;
  cin.ignore(256, '\n');
  for (int i = 0; i < n; ++i) {
    char ch;
    int id, hash;
    scanf("%c", &ch);
    if (ch == '+') {
      scanf("%d%d\n", &id, &hash);
      int x = hash;
      while (true) {
        if (a[x] == 0) {
          a[x] = id;
          mp[id] = x;
          break;
        }
        x = (x + m) % h;
        ++res;
      }
    } else {
      scanf("%d\n", &id);
      a[mp[id]] = 0;
    }
  }
  cout << res << endl;
  return 0;
}
