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