#include <bits/stdc++.h>
using namespace std;
string numToString(long long num) {
  string word;
  stringstream ss;
  ss << num;
  ss >> word;
  return word;
}
long long stringToNum(string word) {
  long long num;
  stringstream ss;
  ss << word;
  ss >> num;
  return num;
}
template <typename t>
void setDigit(t &num, int pos, int digit) {
  string word = numToString(num);
  while (word.length() <= pos) word = '0' + word;
  word[word.length() - pos - 1] = '0' + digit;
  num = stringToNum(word);
}
int dirK[8][2] = {{-2, 1}, {-1, 2}, {1, 2},   {2, 1},
                  {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};
int dir8[8][2] = {{-1, 0}, {-1, 1}, {0, 1},  {1, 1},
                  {1, 0},  {1, -1}, {0, -1}, {-1, -1}};
int dir4[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int i, r, d, n, x, y, p, counter = 0;
  scanf("%d %d %d", &r, &d, &n);
  r -= d;
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &x, &y, &p);
    double dist = x * x + y * y;
    dist = sqrt(dist);
    double distL = dist + p;
    dist -= p;
    if (dist >= r && distL <= r + d) {
      counter++;
    }
  }
  printf("%d\n", counter);
}
