#include <bits/stdc++.h>
using namespace std;
double find(int x, int y) { return (sqrt(x * x + y * y)); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int r, d;
  int t;
  cin >> r >> d;
  cin >> t;
  int c = 0;
  while (t--) {
    int x, y, q;
    cin >> x >> y >> q;
    double l;
    l = find(x, y);
    int a = r - d;
    int b = a + d;
    if (l - q >= a && l + q <= r) c++;
  }
  cout << c << endl;
  return 0;
}
