#include <bits/stdc++.h>
using namespace std;
int main() {
  int R, d, n;
  cin >> R >> d >> n;
  int ans = 0;
  int x, y, r;
  int tmp;
  while (n--) {
    cin >> x >> y >> r;
    tmp = x * x + y * y;
    if (tmp <= (R - r) * (R - r) && tmp >= (R - d + r) * (R - d + r)) ++ans;
  }
  cout << ans;
  return 0;
}
