#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-7;
long double Mod(long double x, long double y) { return sqrt(x * x + y * y); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long double d, r;
  cin >> r >> d;
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    long double x, y, R;
    cin >> x >> y >> R;
    long double m = Mod(x, y);
    if (m - R >= r - d - EPS and R + m <= r + EPS) ++ans;
  }
  cout << ans << endl;
}
