#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int p = 1000000007;
int countbit(int n) { return n == 0 ? 0 : countbit(n / 2) + n % 2; }
int lowbit(int n) { return (n ^ (n - 1)) & n; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long toInt64(string s) {
  istringstream sin(s);
  long long t;
  sin >> t;
  return t;
}
template <typename T>
T sqr(T n) {
  return n * n;
}
template <typename T>
void out(T& v) {
  for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
  cout << endl;
}
class Timer {
 public:
  double start;
  Timer() { start = static_cast<double>(clock()); }
  void out() { cout << "TIME: " << (clock() - start) / CLOCKS_PER_SEC << endl; }
};
void solve() {
  int h, m, n;
  cin >> h >> m >> n;
  vector<int> table(h), busy(h);
  map<int, int> finder;
  long long result = 0;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == '+') {
      int id, t;
      cin >> id >> t;
      int j = 0;
      while (busy[(t + j * m) % h]) j++;
      result += j;
      busy[(t + j * m) % h] = true;
      table[(t + j * m) % h] = id;
      finder.insert((make_pair((id), ((t + j * m) % h))));
    } else {
      int id, t;
      cin >> id;
      t = finder.find(id)->second;
      busy[t] = false;
      finder.erase(id);
    }
  }
  cout << result << endl;
}
int main() {
  Timer timer;
  cout.sync_with_stdio(false);
  cin.sync_with_stdio(false);
  solve();
  return EXIT_SUCCESS;
}
