#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;
const int N = 3e5 + 5, inf = 2e9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int r, d, n, ans = 0;
  cin >> r >> d >> n;
  while (n--) {
    int x, y, rr;
    cin >> x >> y >> rr;
    ld a = (x * x) + (y * y);
    a = sqrt(a);
    if (a + rr <= r && a - rr >= r - d) ans++;
  }
  cout << ans << "\n";
  return 0;
}
