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