#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, d;
  cin >> r >> d;
  int n;
  cin >> n;
  int x[n], y[n], rad[n];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> rad[i];
    long long int dis = x[i] * x[i] + y[i] * y[i];
    if (dis >= 1ll * (r - d + rad[i]) * (r - d + rad[i]) and
        dis <= 1ll * (r - rad[i]) * (r - rad[i])) {
      ans++;
    }
  }
  cout << ans << endl;
}
