#include <bits/stdc++.h>
using namespace std;
bool lies(int x, int y, int z, int r, int d) {
  double center = sqrt(1.0 * x * x + 1.0 * y * y);
  double maxx = center + z;
  double minn = center - z;
  if (center <= r && center >= r - d && maxx <= r && maxx >= r - d &&
      minn <= r && minn >= r - d) {
    return true;
  }
  return false;
}
int main() {
  int r, d, n;
  cin >> r >> d;
  cin >> n;
  int x[n], y[n], z[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (lies(x[i], y[i], z[i], r, d)) {
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
