#include <bits/stdc++.h>
using namespace std;
int t, r, n, ans = 0;
int main() {
  cin >> r >> t >> n;
  for (int i = 1; i <= n; i++) {
    int x, y, p;
    scanf("%d%d%d", &x, &y, &p);
    int dist = x * x + y * y;
    if (dist >= (p + (r - t)) * (p + (r - t)) && dist <= (p + r) * (p + r) &&
        dist >= ((r - t) - p) * ((r - t) - p) && dist <= (r - p) * (r - p))
      ans++;
  }
  cout << ans << endl;
}
