#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, d, n;
  scanf("%d %d", &r, &d);
  scanf("%d", &n);
  int ans = 0, x, y, r_i;
  while (n--) {
    scanf("%d %d %d", &x, &y, &r_i);
    double dist = sqrt((x * x) + (y * y));
    if (dist + r_i <= r && dist - r_i >= r - d && r_i <= d) {
      ans++;
    }
  }
  printf("%d", ans);
  return 0;
}
