#include <bits/stdc++.h>
using namespace std;
int r, d;
int n;
int ans;
int main() {
  cin >> r >> d;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y, r2;
    cin >> x >> y >> r2;
    double dist = sqrt(x * x + y * y);
    if (dist - r2 >= r - d && dist + r2 <= r) ans++;
  }
  cout << ans;
}
