Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on the crust, and he does not really like the crust.

The pizza is a circle of radius r and center at the origin. Pizza consists of the main part — circle of radius r - d with center at the origin, and crust around the main part of the width d. Pieces of sausage are also circles. The radius of the i -th piece of the sausage is r_{i}, and the center is given as a pair (x_{i}, y_{i}).

Gleb asks you to help determine the number of pieces of sausage caught on the crust. A piece of sausage got on the crust, if it completely lies on the crust.


-----Input-----

First string contains two integer numbers r and d (0 ≤ d < r ≤ 500) — the radius of pizza and the width of crust.

Next line contains one integer number n — the number of pieces of sausage (1 ≤ n ≤ 10^5).

Each of next n lines contains three integer numbers x_{i}, y_{i} and r_{i} ( - 500 ≤ x_{i}, y_{i} ≤ 500, 0 ≤ r_{i} ≤ 500), where x_{i} and y_{i} are coordinates of the center of i-th peace of sausage, r_{i} — radius of i-th peace of sausage.


-----Output-----

Output the number of pieces of sausage that lay on the crust.


-----Examples-----
Input
8 4
7
7 8 1
-7 3 2
0 2 1
0 -2 2
-3 -3 1
0 6 2
5 3 1

Output
2

Input
10 8
4
0 0 9
0 0 10
1 0 1
1 0 2

Output
0



-----Note-----

Below is a picture explaining the first example. Circles of green color denote pieces of sausage lying on the crust.

 [Image]

Source: codeforces | Difficulty: EASY
Tags: Geometry


Solutions:
stroka = input()
k = ''
for i in range(0, len(stroka)):
	if stroka[i] == ' ':
		R = int(k)
		k = ''
	else:
		k += stroka[i]
d = int(k)
n = int(input())
x = []
y = []
r = []
answer = 0
for i in range(0, n):
	stroka = input()
	k = ''
	count = 1
	for i in range(0, len(stroka)):
		if stroka[i] == ' ':
			if count == 1:
				x.append(int(k))
			else:
				y.append(int(k))
			count += 1
			k = ''
		else:
			k += stroka[i]
	r.append(int(k))
for i in range(0, n):
	line = (x[i] ** 2 + y[i] ** 2) ** 0.5
	if line - r[i] >= R - d and line + r[i] <= R:
		answer += 1
print(answer)


import math
r = 0
d = 0

def is_sausage_in_crust(x, y, ra):
	x = math.fabs(x)
	y = math.fabs(y)
	ra = math.fabs(ra)
	t = math.sqrt(x ** 2 + y ** 2)
	return float(r - d) <= t - ra and float(r) >= t + ra

def main():
	global r, d
	l = input().split(' ')
	r = math.fabs(int(l[0]))
	d = math.fabs(int(l[1]))
	count = 0
	n = int(input())
	for i in range(0, n):
		l = input().split(' ')
		if is_sausage_in_crust(int(l[0]), int(l[1]), int(l[2])):
			count += 1
	print(count)
main()


import math

def in_crust(x, y, s, d, r):
	return r - d <= math.sqrt(x ** 2 + y ** 2) - s and math.sqrt(x ** 2 + y ** 2) + s <= r

class CodeforcesTask842BSolution:

	def __init__(self):
		self.result = ''
		self.r_d = []
		self.n = 0
		self.circles = []

	def read_input(self):
		self.r_d = [int(x) for x in input().split(' ')]
		self.n = int(input())
		for x in range(self.n):
			self.circles.append([int(y) for y in input().split(' ')])

	def process_task(self):
		is_ = [1 if in_crust(cru[0], cru[1], cru[2], self.r_d[1], self.r_d[0]) else 0 for cru in self.circles]
		self.result = str(sum(is_))

	def get_result(self):
		return self.result
Solution = CodeforcesTask842BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


import math
a1 = input()
a1 = a1.split(' ')
a1 = [int(x) for x in a1]
R = a1[0]
C = a1[1]
t = int(input())
lst = []
for i in range(t):
	d = input()
	d = d.split(' ')
	d = [int(x) for x in d]
	lst.append(d)
c = 0
for i in lst:
	ox = i[0]
	oy = i[1]
	r = i[2]
	d = math.sqrt(math.pow(ox, 2) + math.pow(oy, 2))
	if d + r <= R and d - r >= R - C and (r <= C / 2):
		c += 1
print(c)


def list_from_input():
	return list(map(int, input().split()))

class Snag:

	def __init__(self, x, y, r):
		self.x = x
		self.y = y
		self.r = r

	@classmethod
	def from_input(cls):
		return Snag(*list_from_input())

	def dist_to_pizza_center(self):
		return (self.x ** 2 + self.y ** 2) ** 0.5

	def is_on_board(self, r, d):
		l = self.dist_to_pizza_center()
		return l - self.r >= r - d and l + self.r <= r

def main():
	(r, d) = list_from_input()
	n = int(input())
	count = 0
	for i in range(n):
		next_snack = Snag.from_input()
		if next_snack.is_on_board(r, d):
			count += 1
	print(count)
main()


ip = input()
ipList = ip.split(' ')
rad = int(ipList[0])
d = int(ipList[1])
n = int(input())
x = []
y = []
r = []
for _ in range(n):
	(xi, yi, ri) = list(map(int, input().split(' ')))
	x.append(xi)
	y.append(yi)
	r.append(ri)
p = rad - 0.5 * d
m = 0
hd = d / 2
for j in range(n):
	if r[j] + abs(p - (x[j] ** 2 + y[j] ** 2) ** 0.5) <= d / 2:
		m = m + 1
print(m)


import math

def distance(x1: int, y1: int, x2: int, y2: int) -> float:
	return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)

def solve_case(r: int, w: int, n: int, xi: int, yi: int, ri: int) -> bool:
	d = distance(0, 0, xi, yi)
	sausage_in_cheese = d < r - w + ri
	sausage_in_pizza = r >= d + ri
	return not sausage_in_cheese and sausage_in_pizza
(r, w) = map(int, input().split())
n = int(input())
ans = 0
for _ in range(n):
	(xi, yi, ri) = map(int, input().split())
	ans += solve_case(r, w, n, xi, yi, ri)
print(ans)


from sys import stdin
import math

def distance(x, y):
	return abs(math.sqrt(x * x + y * y))

def check(x, y, rad):
	dist = distance(x, y)
	if dist + rad <= r and dist - rad >= r - d:
		return True
	else:
		return False
(r, d) = list(map(int, input().split()))
n = int(input())
count = 0
for u in range(n):
	(x, y, rad) = list(map(int, input().split()))
	if check(x, y, rad):
		count += 1
print(count)


import math
x = input()
x = x.split(' ')
r = int(x[0])
d = int(x[1])
n = int(input())
result = 0
for i in range(n):
	x = input()
	x = x.split(' ')
	y = int(x[1])
	sr = int(x[2])
	x = int(x[0])
	odleglosc = math.sqrt(x * x + y * y)
	if odleglosc >= r - d:
		if odleglosc <= r:
			if odleglosc - sr >= r - d:
				if odleglosc + sr <= r:
					result += 1
print(result)


(r, d) = list(map(int, input().split()))
n = int(input())
res = 0
for _ in range(n):
	(x, y, ri) = list(map(int, input().split()))
	res += (r - d + ri) ** 2 <= x * x + y * y <= (r - ri) ** 2
print(res)


from math import sqrt

def main():
	(r, d) = map(int, input().split(' '))
	n = int(input())
	ans = 0
	for i in range(n):
		(xi, yi, ri) = map(int, input().split(' '))
		if sqrt(xi * xi + yi * yi) + ri <= r:
			if sqrt(xi * xi + yi * yi) - ri >= r - d:
				ans += 1
	return ans
print(main())


(z, d) = list(map(int, input().split()))
import math
o = 0
for k in range(int(input())):
	(x, y, r) = list(map(int, input().split()))
	p = math.sqrt(abs(x) ** 2 + abs(y) ** 2) + r
	q = p - 2 * r
	if p <= z and q >= z - d:
		o += 1
print(o)


from math import sqrt
from sys import stdin
(R, d) = map(int, stdin.readline().split())
n = int(stdin.readline())
result = 0
for i in range(n):
	(x, y, r) = map(int, stdin.readline().split())
	distance_from_center = sqrt(x * x + y * y)
	if distance_from_center - r >= R - d and distance_from_center + r <= R:
		result += 1
print(result)


import math
(r, d) = map(int, input().split())
c = r - d
t = int(input())
ans = 0
for i in range(t):
	(x, y, a) = map(int, input().split())
	p = math.sqrt(x * x + y * y)
	if p - a >= c and p + a <= r:
		ans += 1
print(ans)


import math
x1 = [int(x1) for x1 in input().split()]
n = int(input())
count = 0
for i in range(n):
	(x, y, r) = input().split()
	x = int(x)
	y = int(y)
	r = int(r)
	if x1[0] - x1[1] <= math.sqrt(x * x + y * y) - r and math.sqrt(x * x + y * y) + r <= x1[0]:
		count = count + 1
print(count)


from math import sqrt
(r, d) = map(int, input().split())
n = int(input())
c = 0
for i in range(n):
	(x, y, r2) = map(int, input().split())
	m = sqrt(x ** 2 + y ** 2)
	if r - d <= m - r2 and m + r2 <= r:
		c += 1
print(c)


import math
print((lambda r, d, n: sum((r - d + ir <= math.hypot(ix, iy) <= r - ir for (ix, iy, ir) in (map(int, input().split()) for _ in range(n)))))(*map(int, input().split()), int(input())))


R = lambda : list(map(int, input().split()))
(r, d) = R()

def ok():
	(x, y, z) = R()
	return 1 if (r - d + z) ** 2 <= x * x + y * y <= (r - z) ** 2 else 0
print(sum((ok() for i in range(int(input())))))


import math

def get_n():
	return int(input())

def get_int_vector():
	return [int(x) for x in input().split()]

def list2string(list):
	result = []
	for i in list:
		result.append(str(i))
	return ':'.join(result)

def string2vector(string):
	return [int(x) for x in string.split(':')]
(r, d) = get_int_vector()
n = get_n()
result = 0
for _ in range(n):
	(x, y, r_i) = get_int_vector()
	dist = x ** 2 + y ** 2
	if dist < (r - d) ** 2 or dist > r ** 2:
		continue
	if dist >= (r - d + r_i) ** 2 and dist <= (r - r_i) ** 2:
		result += 1
print(result)


(R, d) = map(int, input().split())
n = int(input())
cnt = 0
for _ in range(n):
	(x, y, r) = map(int, input().split())
	s = (x ** 2 + y ** 2) ** (1 / 2)
	if s + r <= R and s - r >= R - d:
		cnt += 1
print(cnt)


import math
(r, d) = map(int, input().split())
n = int(input())
count = 0
for t in range(n):
	(x, y, ri) = map(int, input().split())
	d_centre = math.sqrt(x * x + y * y)
	if d_centre - ri >= r - d and d_centre + ri <= r:
		count += 1
print(count)


(r, d) = map(int, input().split())
r -= d
n = int(input())
count = 0
for i in range(n):
	(x, y, rd) = map(int, input().split())
	s = (x * x + y * y) ** 0.5
	if s - r >= rd and r + d >= s + rd:
		count += 1
print(count)


(q, w) = map(int, input().split())
e = 0
r = q - w
for i in range(0, int(input())):
	(a, s, d) = map(int, input().split())
	f = (a * a + s * s) ** 0.5
	if (f + d <= q) & (f - d >= r):
		e += 1
print(e)


(R, D) = map(int, input().split())
cnt = 0
for _ in range(int(input())):
	(x, y, r) = map(int, input().split())
	d = (x * x + y * y) ** 0.5
	if r + d <= R and d - r >= R - D:
		cnt += 1
print(cnt)


from math import hypot
(R, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	if R - d <= hypot(x, y) - r and hypot(x, y) + r <= R:
		ans += 1
print(ans)


from math import sqrt
[r, d] = list(map(int, input().split()))
s = 0
n = int(input())
for i in range(n):
	[x, y, R] = list(map(int, input().split()))
	if sqrt(x ** 2 + y ** 2) - R >= r - d and sqrt(x ** 2 + y ** 2) + R <= r:
		s += 1
print(s)


(r, d) = [int(k) for k in input().split()]
count = 0
for i in range(int(input())):
	(x, y, rs) = [int(j) for j in input().split()]
	main_dis = (x ** 2 + y ** 2) ** (1 / 2)
	max_dis = main_dis + rs
	min_dis = main_dis - rs
	if max_dis <= r and min_dis >= r - d:
		count += 1
print(count)


import math
data = input().split(' ')
r = int(data[0])
d = int(data[1])
n = int(input())
count = 0
for c in range(0, n):
	data = input().split(' ')
	x = int(data[0])
	y = int(data[1])
	rr = int(data[2])
	dd = math.sqrt(x ** 2 + y ** 2)
	if dd + rr <= r and dd - rr >= r - d:
		count = count + 1
print(count)


from math import sqrt
(r, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(x, y, ri) = map(int, input().split())
	n_dist = sqrt(x ** 2 + y ** 2) - ri
	f_dist = n_dist + 2 * ri
	if n_dist >= r - d and f_dist <= r:
		ans += 1
print(ans)


from sys import stdin, stdout
(r, d) = map(int, stdin.readline().rstrip().split())
n = int(stdin.readline().rstrip())
crust = 0
for _ in range(n):
	(x, y, ri) = map(int, stdin.readline().rstrip().split())
	z = (x ** 2 + y ** 2) ** 0.5
	if z - ri >= r - d and z + ri <= r:
		crust += 1
print(crust)


def list_input():
	return list(map(int, input().split()))

def map_input():
	return map(int, input().split())

def map_string():
	return input().split()

def incrust(d, r, dist):
	return r - d <= dist and dist <= r
from math import sqrt
(r, d) = map_input()
n = int(input())
ans = 0
for i in range(n):
	(x, y, z) = map_input()
	if incrust(d, r, sqrt(x ** 2 + y ** 2) + z) and incrust(d, r, sqrt(x ** 2 + y ** 2) - z):
		ans += 1
print(ans)


import math

def dist(x, y):
	return math.sqrt(x ** 2 + y ** 2)
(R, d) = map(int, input().split())
n = int(input())
count = 0
R -= d
for i in range(n):
	(x, y, r) = map(int, input().split())
	if dist(x, y) - r >= R and dist(x, y) + r <= R + d:
		count += 1
print(count)


while True:
	radio = input()
	a = radio.find(' ')
	r = int(radio[0:a])
	d = int(radio[int(a) + 1:])
	n = int(input())
	if 0 <= d < r <= 500 and 1 <= n <= 10 ** 5:
		break
	else:
		continue
sausage_crust = 0
for i in range(n):
	while True:
		sausage = input()
		o = sausage.find(' ')
		x = int(sausage[0:int(o)])
		p = sausage.find(' ', int(o) + 1)
		y = int(sausage[int(o) + 1:int(p)])
		ri = int(sausage[int(p) + 1:])
		if -500 <= x <= 500 and -500 <= y <= 500 and (0 <= ri <= 500):
			break
		else:
			continue
	if (x ** 2 + y ** 2) ** (1 / 2) - ri >= r - d and (x ** 2 + y ** 2) ** (1 / 2) + ri <= r:
		sausage_crust = sausage_crust + 1
	else:
		continue
print(sausage_crust)


import math

def main():
	(R, D) = [int(i) for i in input().split()]
	N = int(input())
	qtd = 0
	for n in range(N):
		(x, y, r) = [int(i) for i in input().split()]
		k = math.sqrt(x * x + y * y)
		if k - r >= R - D and k + r <= R:
			qtd += 1
	print(qtd)
main()


import math as mt
(r, d) = map(int, input().split())
n = int(input())
compteur = 0
for loop in range(n):
	(x, y, m) = map(int, input().split())
	dist1 = mt.sqrt(x ** 2 + y ** 2)
	if dist1 - (r - d) >= m and r >= dist1 + m:
		compteur += 1
print(compteur)


from math import sqrt
dist = lambda p: sqrt(sum([d * d for d in p]))
inCrust = lambda l, r, rl, rr: l - r >= rl and l + r <= rr
(rr, d) = list(map(int, input().split()))
xyrl = [list(map(int, input().split())) for _ in range(int(input()))]
print(sum([inCrust(dist(xyr[:2]), xyr[2], rr - d, rr) for xyr in xyrl]))


(r, d) = list(map(int, input().split()))
n = int(input())
c = 0
k = r - d
while n:
	n -= 1
	(x1, y1, r1) = list(map(int, input().split()))
	m = (x1 ** 2 + y1 ** 2) ** 0.5
	if m - r1 >= k and m + r1 <= r:
		c += 1
print(c)


(r, d) = [int(x) for x in input().split()]
n = int(input())
num = 0
for i in range(n):
	(xi, yi, ri) = [int(x) for x in input().split()]
	s = xi * xi + yi * yi
	a = (r - d + ri) ** 2
	b = (r - ri) ** 2
	if a <= s and s <= b:
		num += 1
print(num)


def R():
	return map(int, input().split())
(r, d) = R()
r0 = r - d
n = int(input())
c = 0
for _ in range(n):
	(x, y, ri) = R()
	if (r0 + ri) ** 2 <= x ** 2 + y ** 2 <= (r - ri) ** 2:
		c += 1
print(c)


from math import sqrt
rd = list(map(int, input().strip().split()))
r = rd[0]
d = rd[1]
n = int(input().strip())
count = 0
for i in range(n):
	query = list(map(int, input().strip().split()))
	x = query[0]
	y = query[1]
	R = query[2]
	D = sqrt(x * x + y * y)
	if D >= r - d + R and D <= r - R:
		count += 1
print(count)


def dist(x, y):
	from math import sqrt
	return sqrt(x * x + y * y)
(r, d) = map(int, input().split())
n = int(input())
R = 0
t = r - d
for k in range(n):
	(x, y, i) = map(int, input().split())
	if dist(x, y) - i >= t and dist(x, y) + i <= r:
		R += 1
print(R)


import math
(R, d) = [int(x) for x in input().split()]
rs = R - d
n = int(input())
arr = []
for i in range(n):
	arr.append([int(x) for x in input().split()])

def main(sausages):
	count = 0
	for sausage in sausages:
		(x, y, r) = (sausage[0], sausage[1], sausage[2])
		if x * x + y * y >= (rs + r) * (rs + r) and x * x + y * y <= (R - r) * (R - r):
			count += 1
	return count
print(main(arr))


import math
(r, d) = [int(x) for x in input().split()]
n = int(input())
ans = 0
for _ in range(n):
	(xi, yi, ri) = [int(x) for x in input().split()]
	piecedistance = math.hypot(xi, yi)
	if piecedistance - ri >= r - d and piecedistance + ri <= r:
		ans += 1
print(ans)


import math

def dist(x1, y1, x2, y2):
	x = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)
	x = math.sqrt(x)
	return x
(rad, d) = map(int, input().split())
base = rad - d
n = int(input())
ct = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	d = dist(0, 0, x, y)
	if d - r >= base and d + r <= rad:
		ct += 1
print(ct)


import math
(a, b) = map(int, input().split())
n = int(input())
c = 0
while n > 0:
	(x, y, r) = map(int, input().split())
	d1 = x * x + y * y
	if pow(d1, 0.5) + r <= a and pow(d1, 0.5) - r >= a - b:
		c = c + 1
	n = n - 1
print(c)


(r, d) = map(int, input().split())
n = int(input())
c = 0
for _ in range(n):
	(x, y, r1) = map(int, input().split())
	s = (x ** 2 + y ** 2) ** 0.5
	if r - d <= s - r1 and s + r1 <= r:
		c += 1
print(c)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def dist(x, y, c, d):
	return mt.sqrt((x - c) ** 2 + (y - d) ** 2)

def circle(x1, y1, x2, y2, r1, r2):
	distSq = ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5
	if distSq + r2 <= r1:
		return True
	else:
		return False
(n, d) = M()
m = I()
c = 0
for i in range(m):
	(a, b, r) = M()
	if circle(0, 0, a, b, n, r):
		x = dist(0, 0, a, b)
		if x >= n - d + r:
			c += 1
print(c)


import math
(r, d) = map(int, input().split())
cnt = 0
for _ in range(int(input())):
	(x, y, r1) = map(int, input().split())
	if math.sqrt(x ** 2 + y ** 2) + r1 <= r and math.sqrt(x ** 2 + y ** 2) - r1 >= r - d:
		cnt += 1
print(cnt)


import math
(m, d) = map(int, input().split())
n = int(input())
count = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	le = math.sqrt(x * x + y * y)
	if m - d <= le - r and le + r <= m:
		count += 1
print(count)


import math
(r, d) = input().split()
radius = int(r)
length_crust = int(d)
sausage_on_pizza = 0
total_sausages = int(input())
for x in range(0, total_sausages):
	sausage_details = input().split()
	distance_sausage = math.sqrt(int(sausage_details[0]) ** 2 + int(sausage_details[1]) ** 2)
	if distance_sausage <= radius and distance_sausage >= radius - length_crust:
		if distance_sausage + int(sausage_details[2]) <= radius and distance_sausage - int(sausage_details[2]) >= radius - length_crust:
			sausage_on_pizza += 1
print(sausage_on_pizza)


from math import sqrt
(r, d) = map(int, input().split())
n = int(input())
crust = r - d
counter = 0
for i in range(n):
	a = list(map(int, input().split()))
	dis = sqrt(a[0] ** 2 + a[1] ** 2)
	if dis >= crust + a[2] and dis + a[2] <= r:
		counter += 1
print(counter)


import math
(r, d) = map(int, input().split())
pieces = int(input())
count = 0
for i in range(1, pieces + 1):
	(x, y, ri) = map(int, input().split())
	gip = math.sqrt(x ** 2 + y ** 2)
	if r - d + ri <= gip <= r - ri:
		count += 1
print(count)


def distance(x, y):
	return (x ** 2 + y ** 2) ** 0.5
(r, d) = map(int, input().split())
count = 0
for i in range(int(input())):
	(x, y, ri) = map(int, input().split())
	dis = distance(x, y)
	if dis - ri >= r - d and dis + ri <= r and (distance(x, y) >= r - d):
		count += 1
print(count)


from __future__ import print_function, division
from sys import stdin
(r, d) = map(int, stdin.readline().split())
n = int(stdin.readline())
ans = 0
for i in range(n):
	(x, y, dr) = map(int, stdin.readline().split())
	if x ** 2 + y ** 2 < (r - d + dr) ** 2:
		continue
	if x ** 2 + y ** 2 > (r - dr) ** 2:
		continue
	ans += 1
print(ans)


from math import sqrt

def dist(x1, y1):
	return sqrt(x1 * x1 + y1 * y1)
(r, d) = map(int, input().split())
n = int(input())
res = 0
for i in range(n):
	(x, y, i) = map(int, input().split())
	if dist(x, y) - i >= r - d and dist(x, y) + i <= r:
		res += 1
print(res)


import math
(c1, c2) = input().split(' ')
c1 = int(c1)
c2 = int(c2)
jp = int(input())
x = 0
h = 0
while x < jp:
	(a, b, c) = input().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	p = a * a + b * b
	d = math.sqrt(p)
	if d + c <= c1 and d - c >= c1 - c2:
		h += 1
		x += 1
	else:
		x += 1
print(h)


(r, d) = map(int, input().strip().split())
c = 0
low_lim = r - d
up_lim = r
for i in range(int(input().strip())):
	(x, y, ri) = map(int, input().strip().split())
	orig_d = (x ** 2 + y ** 2) ** 0.5
	if orig_d - ri >= low_lim and orig_d + ri <= up_lim:
		c += 1
print(c)


(r, d) = list(map(int, input().split()))
n = int(input())
a = []
b = []
for _ in range(n):
	(x, y, z) = list(map(int, input().split()))
	m = (x ** 2 + y ** 2) ** 0.5
	a.append(m - z)
	b.append(m + z)
y = 0
for i in range(n):
	if a[i] >= r - d and b[i] <= r:
		y += 1
print(y)


(r, d) = map(int, input().split())
n = int(input())
c = []
center = [0, 0]
for i in range(n):
	s = list(map(int, input().split()))
	c.append(s)

def dis(x, y):
	r = ((x[1] - y[1]) ** 2 + (x[0] - y[0]) ** 2) ** (1 / 2)
	return r
counter = 0
for i in range(n):
	if dis(center, c[i]) + c[i][2] <= r and dis(center, c[i]) - c[i][2] >= r - d:
		counter += 1
print(counter)


import sys
import math
(cc, rc) = map(int, input().split())
rc = cc - rc
n = int(input())
ret = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	dist = math.pow(x * x + y * y, 0.5)
	if rc <= dist - r <= cc and rc <= dist + r <= cc:
		ret += 1
print(ret)


def getDistance(xi, yi):
	return (xi ** 2 + yi ** 2) ** 0.5
data = input().split()
(pizza, crust) = (int(data[0]), int(data[1]))
n = int(input())
pizzaWithoutCrust = pizza - crust
count = 0
for i in range(0, n):
	data = input().split()
	(xi, yi, ri) = (int(data[0]), int(data[1]), int(data[2]))
	distanceToCenter = getDistance(xi, yi)
	distanceA = distanceToCenter - ri
	distanceB = distanceToCenter + ri
	if distanceA >= pizzaWithoutCrust and distanceB <= pizza:
		count += 1
print(count)


(r, x) = [int(i) for i in input().split()]
n = int(input())
total = 0
for i in range(n):
	[a, b, c] = [int(i) for i in input().split()]
	d = abs((a * a + b * b) ** (1 / 2))
	if d + c <= r and max(0, d - c) >= r - x:
		total += 1
print(total)


(r, d) = [int(x) for x in input().split()]
n = int(input())
cnt = 0
for i in range(n):
	(x, y, ri) = [int(x) for x in input().split()]
	if (r - d + ri) ** 2 <= x ** 2 + y ** 2 <= (r - ri) ** 2:
		cnt += 1
print(cnt)


import math

def calc(x1, y1, x2, y2):
	dist = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	return dist
(r, d) = map(int, input().split())
r1 = r - d
ans = 0
n = int(input())
for i in range(n):
	(x, y, r2) = map(int, input().split())
	dist = calc(0, 0, x, y)
	if dist >= r1 + r2 and dist <= r - r2:
		ans += 1
print(ans)


cnt = 0
(r, d) = map(int, input().split())
n = int(input())
for i in range(n):
	(x, y, r1) = map(int, input().split())
	if (x * x + y * y) ** 0.5 - r1 >= r - d and (x * x + y * y) ** 0.5 + r1 <= r:
		cnt += 1
print(cnt)


(r, d) = map(int, input().split())
n = int(input())
rs = 0
for i in range(n):
	(x, y, rr) = map(int, input().split())
	if (rr + r - d) ** 2 <= x * x + y * y and (r - rr) ** 2 >= x * x + y * y:
		rs += 1
print(rs)


read = lambda : map(int, input().split())
(R, d) = read()
n = int(input())
cnt = 0
for i in range(n):
	(x, y, r) = read()
	p = (x ** 2 + y ** 2) ** 0.5
	if p - r >= R - d and p + r <= R:
		cnt += 1
print(cnt)


I = [int(x) for x in input().split()]
n = int(input())
k = 0
for _ in range(n):
	I1 = [int(x) for x in input().split()]
	temp = I1[0] ** 2 + I1[1] ** 2
	if temp ** (1 / 2) - I1[2] >= I[0] - I[1] and temp ** (1 / 2) + I1[2] <= I[0]:
		k = k + 1
print(k)


class Salami:

	def __init__(self, x, y, r):
		(self.x, self.y, self.r) = (x, y, r)
(r, d) = map(int, input().split())
R = r - d
n = int(input())
salamis = [None] * n
for i in range(n):
	(x, y, z) = map(int, input().split())
	salamis[i] = Salami(x, y, z)
ans = 0

def ro(x, y):
	return (x ** 2 + y ** 2) ** (1 / 2)
for s in salamis:
	if ro(s.x, s.y) < s.r + R:
		continue
	if ro(s.x, s.y) + min(r, s.r) <= max(s.r, r):
		ans += 1
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
(r, d) = list(map(int, input().split()))
cnt = 0
for i in range(int(input())):
	(x, y, ri) = list(map(int, input().split()))
	dist = math.sqrt(x ** 2 + y ** 2)
	if dist >= r - d and dist <= r:
		if dist - (r - d) >= ri and r - dist >= ri:
			cnt += 1
print(cnt)


from math import sqrt
(r, d) = list(map(int, input().split()))
n = int(input())
res = 0
for _ in range(n):
	(x, y, ri) = list(map(int, input().split()))
	if r - ri >= sqrt(x * x + y * y) >= r - d + ri:
		res += 1
print(res)


3

def read_ints():
	return [int(i) for i in input().split()]
(r, d) = read_ints()
n = int(input())
cnt = 0
for i in range(n):
	(x, y, r_i) = read_ints()
	if x ** 2 + y ** 2 >= (r - d + r_i) ** 2 and x ** 2 + y ** 2 <= (r - r_i) ** 2:
		cnt += 1
print(cnt)


(r, d) = list(map(int, input().split()))
n = int(input())
ans = 0
for _ in range(n):
	(xi, yi, ri) = list(map(int, input().split()))
	if (r - d + ri) ** 2 <= xi ** 2 + yi ** 2 and xi ** 2 + yi ** 2 <= (r - ri) ** 2:
		ans += 1
print(ans)


(R, d) = map(int, input().split())
n = int(input())
count = 0
for _ in range(n):
	(x, y, r) = map(int, input().split())
	if 2 * r <= d:
		dis = (x ** 2 + y ** 2) ** (1 / 2)
		mind = dis - r
		maxd = dis + r
		if mind >= R - d and maxd <= R:
			count += 1
print(count)


import math
(r, d) = map(int, input().split())
n = int(input())
count = 0
for _ in range(n):
	(x, y, ri) = map(int, input().split())
	(x, y, ri) = (abs(x), abs(y), abs(ri))
	least = math.sqrt(x * x + y * y) - ri
	greatest = math.sqrt(x * x + y * y) + ri
	if least >= r - d and greatest <= r:
		count += 1
print(count)


[r, d] = list(map(int, input().split()))
n = int(input())
r_in = r - d
r_out = r
res = 0
for i in range(n):
	[x, y, rs] = list(map(int, input().split()))
	dist_sq = x * x + y * y
	if dist_sq >= (r_in + rs) * (r_in + rs) and dist_sq <= (r_out - rs) * (r_out - rs):
		res += 1
print(res)


import math
arr = input().split()
r = int(arr[0])
d = int(arr[1])
n = int(input())
ctr = 0
for i in range(n):
	arr = input().split()
	x = int(arr[0])
	y = int(arr[1])
	z = int(arr[2])
	x = abs(x)
	y = abs(y)
	l = math.sqrt(x * x + y * y)
	l -= z
	m = l + z + z
	if l >= r - d and m <= r:
		ctr += 1
print(str(ctr))


import math

def distEcld(x2, x1, y2, y1):
	x = pow(x2 - x1, 2)
	y = pow(y2 - y1, 2)
	ab = pow(x + y, 0.5)
	return ab
x = input()
num_ling = 0
val = x.split(' ')
raio = int(val[0])
d_borda = int(val[1])
ling = int(input())
for a in range(ling):
	linha = input()
	linha = linha.split(' ')
	cordX1 = int(linha[0])
	cordY1 = int(linha[1])
	dia_ling = int(linha[2])
	dAB = distEcld(cordX1, 0, cordY1, 0)
	sizeBorda = raio - d_borda
	dPontoInfernoAB = dAB - dia_ling
	dPontoCeuAB = dAB + dia_ling
	if dPontoInfernoAB >= sizeBorda:
		if dPontoCeuAB <= raio:
			num_ling = num_ling + 1
print(num_ling)


def ro(x1, y1, x2, y2):
	return (x1 - x2) ** 2 + (y2 - y1) ** 2
(r, d) = map(int, input().split())
n = int(input())
eps = 10 ** (-5)
ans = 0
for i in range(n):
	(xi, yi, ri) = map(int, input().split())
	d1 = ro(0, 0, xi, yi)
	if d1 >= (ri + r - d) ** 2 and d1 <= (r - ri) ** 2 and (r > ri):
		ans += 1
print(ans)


import math
(r, d) = [int(x) for x in input().split()]
small_r = r - d
large_r = r
count = 0
for _ in range(int(input())):
	(x, y, ra) = [int(x) for x in input().split()]
	dist1 = math.sqrt(x * x + y * y)
	inside1 = dist1 - small_r < 0
	inside2 = dist1 - large_r <= 0
	if not inside1 and inside2:
		if ra <= dist1 - small_r:
			if ra <= abs(dist1 - large_r):
				count += 1
print(count)


import math
from collections import defaultdict

def input_ints():
	return list(map(int, input().split()))

def solve():
	(r, d) = input_ints()
	n = int(input())
	ans = 0
	for i in range(n):
		(x, y, p) = input_ints()
		if (r - d + p) ** 2 <= x ** 2 + y ** 2 <= (r - p) ** 2:
			ans += 1
	print(ans)
solve()


(r, d) = map(int, input().split())

def c(xi, yi, ri):
	r2 = xi ** 2 + yi ** 2
	return r2 >= (r + ri - d) ** 2 and r2 <= (r - ri) ** 2
print(sum((c(*map(int, input().split())) for i in range(int(input())))))


import math
(r, d) = list(map(int, input().split()))
n = int(input())
t = 0
for _ in range(n):
	(x, y, rr) = list(map(int, input().split()))
	z = math.sqrt(x ** 2 + y ** 2)
	if z - rr >= r - d and z + rr <= r:
		t += 1
print(t)


(R, d) = map(int, input().split())
n = int(input())
c = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	p = (x ** 2 + y ** 2) ** 0.5
	if p <= R and p >= R - d:
		if p - r >= R - d and p + r <= R:
			c += 1
print(c)


R = lambda : list(map(int, input().split()))
(r, d) = R()

def ok():
	(xi, yi, ri) = R()
	return 1 if (r - d + ri) ** 2 <= xi ** 2 + yi ** 2 <= (r - ri) ** 2 else 0
print(sum((ok() for i in range(int(input())))))


c = []
a = map(int, input().split())
b = int(input())
for i in range(b):
	e = map(int, input().split())
	f = [a for a in e]
	c.append(f)
y = [a for a in a]
z = 0
for j in range(b):
	d = (c[j][0] ** 2 + c[j][1] ** 2) ** 0.5
	if y[0] - y[1] <= d - c[j][2] <= y[0] and y[0] - y[1] <= d + c[j][2] <= y[0]:
		z += 1
print(z)


import math

def distance(x1, y1, x2, y2):
	dx = x2 - x1
	dx *= dx
	dy = y2 - y1
	dy *= dy
	return math.sqrt(dx + dy)

class Pizza:

	def __init__(self, r, d):
		self.r = r
		self.d = d

	def onCrust(self, x, y, r):
		dist = distance(0, 0, x, y)
		if dist - r < self.r - self.d:
			return False
		if dist + r > self.r:
			return False
		return True

def ni():
	s = input()
	while len(s) == 0:
		s = input()
	try:
		return int(s)
	except:
		return 0

def nia():
	s = input()
	while len(s) == 0:
		s = input()
	s = s.split()
	iVal = []
	for i in range(len(s)):
		iVal.append(int(s[i]))
	return iVal

def test():
	pizza = Pizza(8, 4)
	print(pizza.onCrust(7, 8, 1) == False)
	print(pizza.onCrust(-7, 3, 2) == False)
	print(pizza.onCrust(0, 2, 1) == False)
	print(pizza.onCrust(0, -2, 2) == False)
	print(pizza.onCrust(-3, -3, 1) == False)
	print(pizza.onCrust(0, 6, 2) == True)
	print(pizza.onCrust(5, 3, 1) == True)

def solve():
	rd = nia()
	T = ni()
	pizza = Pizza(rd[0], rd[1])
	count = 0
	for i in range(T):
		sausage = nia()
		if pizza.onCrust(sausage[0], sausage[1], sausage[2]):
			count += 1
	print(count)
solve()


(r, d) = [int(i) for i in input().split()]
res = 0
for _ in range(int(input())):
	(x, y, ri) = [int(i) for i in input().split()]
	if r - ri >= (x * x + y * y) ** 0.5 >= r - d + ri:
		res += 1
print(res)


from sys import stdin
from math import hypot
(r, d) = [int(i) for i in stdin.readline().split()]
r1 = r - d
n = int(stdin.readline())
ans = 0
eps = 1e-07

def ge0(a):
	return a >= 0 or abs(a) <= eps
for i in range(n):
	(x, y, r2) = [int(i) for i in stdin.readline().split()]
	d = hypot(x, y)
	if ge0(d - r1 - r2) and ge0(r - d - r2):
		ans += 1
print(ans)


(r_pizza, d) = map(int, input().split())
n = int(input())
count = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	distance = (x * x + y * y) ** 0.5
	if distance - r >= r_pizza - d and distance + r <= r_pizza:
		count += 1
print(count)


from sys import stdout
from random import randint
from math import *
(r, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(x, y, ri) = map(int, input().split())
	if hypot(x, y) - ri >= r - d and hypot(x, y) + ri <= r:
		ans += 1
print(ans)


(R, D) = map(int, input().split())
D = R - D
n = int(input())
from math import sqrt
cnt = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	p = x * x + y * y
	if (D + r) ** 2 <= p <= (R - r) ** 2:
		cnt += 1
print(cnt)


(R, d) = [int(i) for i in input().split()]
n = int(input())
ans = 0
for i in range(n):
	(x, y, r) = [int(i) for i in input().split()]
	dist = (x * x + y * y) ** 0.5
	if dist - r >= R - d and dist + r <= R:
		ans += 1
print(ans)


import math
import time
(r, d) = map(int, input().split())
n = int(input())
global k
k = 0
for i in range(n):
	(x, y, w) = map(int, input().split())
	l = (x ** 2 + y ** 2) ** (1 / 2)
	if l - w >= r - d and l + w <= r:
		k += 1
print(k)


from sys import stdin
from math import sqrt
(r, d) = list(map(int, stdin.readline().split()))
n = int(stdin.readline())
data = []
for i in range(0, n):
	data.append(list(map(int, stdin.readline().split())))
rs = 0
for i in range(0, n):
	D = sqrt(data[i][0] ** 2 + data[i][1] ** 2)
	rs += 1 if r - d <= D - data[i][2] and r >= D + data[i][2] else 0
print(rs)


from math import sqrt
(r, d) = [int(element) for element in input().split(' ')]
n = int(input())
res = 0
for i in range(n):
	(x, y, r_s) = [int(element) for element in input().split(' ')]
	if r - d + r_s <= sqrt(x ** 2 + y ** 2) <= r - r_s:
		res += 1
print(res)


(r, d) = map(int, input().split())
n = int(input())
ans = 0
for _ in range(n):
	(a, b, c) = map(int, input().split())
	if (a * a + b * b) ** 0.5 - c >= r - d and (a * a + b * b) ** 0.5 + c <= r:
		ans += 1
print(ans)


import sys
(r, d) = map(int, input().split())
n = int(input())
res = 0
for i in range(n):
	(xi, yi, ri) = map(int, input().split())
	dd = (xi ** 2 + yi ** 2) ** 0.5
	if dd + ri <= r and dd - ri >= r - d:
		res += 1
print(res)


(r, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(xi, yi, ri) = map(int, input().split())
	d2 = xi ** 2 + yi ** 2
	if d2 >= (r - d + ri) ** 2 and d2 <= (r - ri) ** 2:
		ans += 1
print(ans)


(r, d) = map(int, input().split())
t1 = r - d
s = 0
for i in range(int(input())):
	(x, y, R) = map(int, input().split())
	q = x * x + y * y
	if q >= (t1 + R) ** 2 and q <= (r - R) ** 2:
		s += 1
print(s)


class Callbass:

	def __init__(self, x, y, r):
		self.x = x
		self.y = y
		self.r = r

	def into(self, other):
		dx = self.x - other.x
		dy = self.y - other.y
		distance = (dx * dx + dy * dy) ** 0.5
		return distance + other.r <= self.r

	def intersection(self, other):
		dx = self.x - other.x
		dy = self.y - other.y
		distance = (dx * dx + dy * dy) ** 0.5
		return distance < self.r + other.r
(r, d) = map(int, input().split())
list_of_callbass = []
for i in range(int(input())):
	iterator = map(int, input().split())
	callbass = Callbass(*iterator)
	list_of_callbass.append(callbass)
pizza = Callbass(0, 0, r)
pizza_taste = Callbass(0, 0, r - d)
count = 0
for callbass in list_of_callbass:
	into = pizza.into(callbass)
	not_into_taste = not pizza_taste.intersection(callbass)
	if into and not_into_taste:
		count += 1
print(count)


def dist(i, j):
	return (i ** 2 + j ** 2) ** 0.5
(r, d) = map(int, input().split())
count = 0
for i in range(int(input())):
	(x, y, r1) = map(int, input().split())
	d1 = dist(x, y)
	if d1 + r1 <= r and r - d <= d1 - r1:
		count += 1
print(count)


import math
(r, d) = map(int, input().split())
n = int(input())
o = 0
for i in range(n):
	(x, y, rad) = map(int, input().split())
	l = math.sqrt(x * x + y * y)
	if l - rad >= r - d and l + rad <= r:
		o += 1
print(o)


(r, d) = map(int, input().split())
b = r - d
n = int(input())
c = 0
for i in range(n):
	(x, y, rr) = map(int, input().split())
	a = (x ** 2 + y ** 2) ** 0.5
	if a - rr >= b and a + rr <= r:
		c += 1
print(c)


import math
A = input().split()
A = [int(i) for i in A]
R = A[0]
D = A[1]
N = int(input())
saussage_count = 0
for i in range(0, N):
	B = input().split()
	B = [int(j) for j in B]
	x = B[0]
	y = B[1]
	r = B[2]
	d = math.sqrt(x * x + y * y)
	if d - r >= R - D and d + r <= R:
		saussage_count += 1
print(saussage_count)


from math import *
import itertools as it
from collections import *
EPS = 1e-09

def get_int():
	return int(input().strip())

def get_string():
	return input().strip()

def get_array():
	return list(map(int, input().strip().split(' ')))

def print_array(a, glue=' '):
	print(glue.join(map(str, a)))

def print_grid(grid, glue=' '):
	for row in grid:
		print_array(row, glue)

def solve():
	(R, D) = get_array()
	n = get_int()
	r = []
	cnt = 0
	for i in range(n):
		(x, y, z) = get_array()
		d = sqrt(x ** 2 + y ** 2)
		if d + z <= R and d - z >= R - D:
			cnt += 1
	return cnt
ntest = 1
for _ in range(ntest):
	print(solve())


(r, d) = map(int, input().split())
n = int(input())
p = []
for i in range(n):
	a = list(map(int, input().split()))
	p.append(a)
r1 = r - d
ans = 0
for i in range(n):
	r2 = (p[i][0] ** 2 + p[i][1] ** 2) ** 0.5
	if r2 >= r1 + p[i][2] and r2 + p[i][2] <= r:
		ans += 1
print(ans)


(r, d) = map(int, input().split())
n = int(input())
ans = 0
for _ in range(n):
	(x, y, k) = map(int, input().split())
	dc = (x * x + y * y) ** 0.5
	if dc + k <= r and dc - k >= r - d:
		ans += 1
print(ans)


(r, d) = map(int, input().split())
n = int(input())
l = 0
for i in range(n):
	(x, y, m) = map(int, input().split())
	k = (x ** 2 + y ** 2) ** 0.5
	if k - m >= r - d and k + m <= r:
		l += 1
print(l)


(r, d) = map(int, input().split())
n = int(input())
res = 0
for _ in range(n):
	(xi, yi, ri) = map(int, input().split())
	si = (xi * xi + yi * yi) ** 0.5
	if si - ri >= r - d and si + ri <= r:
		res += 1
print(res)


(r, d) = map(int, input().split())
n = int(input())
r1 = r - d
ans = 0
for i in range(n):
	(x, y, z) = map(int, input().split())
	r2 = (x ** 2 + y ** 2) ** 0.5
	if r2 >= r1 + z and r2 + z <= r:
		ans += 1
print(ans)


(r, d) = input().split()
(r, d) = (int(r), int(d))
n = int(input())
ans = 0
for i in range(n):
	(x, y, ri) = input().split()
	(x, y, ri) = (int(x), int(y), int(ri))
	di = abs(complex(x, y))
	if di - ri >= r - d and ri + di <= r:
		ans += 1
print(ans)


(r, d) = [int(i) for i in input().split()]
n = int(input())
N = 0
for i in range(n):
	(xi, yi, ri) = [int(i) for i in input().split()]
	di = (xi ** 2 + yi ** 2) ** (1 / 2.0)
	if r - d <= di <= r:
		w = min([di - r + d, r - di])
		if ri <= w:
			N += 1
print(N)


(r, d) = list(map(int, input().split()))
n = int(input())
res = 0
for i in range(n):
	(x, y, f) = list(map(int, input().split()))
	res += (r - d + f) ** 2 <= x ** 2 + y ** 2 <= (r - f) ** 2
print(res)


import math
(r, d) = [int(j) for j in input().split()]
n = int(input())
a = r - d
c = 0
for i in range(n):
	(x, y, r2) = [int(j) for j in input().split()]
	p = math.sqrt(x ** 2 + y ** 2)
	if p + r2 <= r and p - r2 >= a:
		c += 1
print(c)


(r, d) = map(int, input().split())
n = int(input())
count = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	l = (a ** 2 + b ** 2) ** (1 / 2)
	if r - d <= l - c <= l + c <= r:
		count += 1
print(count)


(R, d) = [int(x) for x in input().strip().split()]
n = int(input().strip())
sausages = 0
for i in range(n):
	(x, y, r) = [int(x) for x in input().strip().split()]
	center = x * x + y * y
	if (R - d + r) * (R - d + r) <= center <= (R - r) * (R - r):
		sausages += 1
print(sausages)


(r, d) = map(int, input().split())
n = int(input())
ans = 0
for _ in range(n):
	(x, y, p) = map(int, input().split())
	if x * x + y * y >= (r - d + p) * (r - d + p) and x * x + y * y <= (r - p) * (r - p):
		ans += 1
print(ans)


(r, d) = map(int, input().split())
n = int(input())
k = 0
for i in range(n):
	(x, y, rr) = map(int, input().split())
	if (x * x + y * y) ** 0.5 - rr >= r - d and (x * x + y * y) ** 0.5 + rr <= r:
		k += 1
print(k)


import math

def dist(x, y):
	return math.sqrt(x * x + y * y)

def lol(x, y, c):
	z = dist(x, y)
	if z - c >= low and z + c <= high:
		return 1
	return 0
(r, d) = map(int, input().split())
low = r - d
high = r
n = int(input())
ans = 0
for _ in range(n):
	(x, y, c) = map(int, input().split())
	if lol(x, y, c):
		ans += 1
print(ans)


from math import sqrt
count = 0
(r, d) = [int(i) for i in input().split()]
n = int(input())
for i in range(n):
	(x, y, r_k) = [int(i) for i in input().split()]
	dist = sqrt(x ** 2 + y ** 2)
	if dist - r_k >= r - d and dist + r_k <= r:
		count += 1
print(count)


import math
from sys import stdin, stdout

def main():
	x = stdin.readline().split()
	r = int(x[0])
	d = int(x[1])
	r -= d
	n = int(stdin.readline())
	ans = 0
	for i in range(n):
		x = stdin.readline().split()
		a = int(x[0])
		b = int(x[1])
		ri = int(x[2])
		D = math.sqrt(a * a + b * b)
		if D - ri >= r and d >= 2 * ri and (D + ri <= r + d):
			ans += 1
	print(ans)
main()


(R, d) = map(int, input().split())
n = int(input())
num = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	q = (x ** 2 + y ** 2) ** 0.5
	if R - d <= q - r and q + r <= R:
		num += 1
print(num)


(r, d) = map(int, input().split())
r -= d
n = int(input())
k = 0
for _ in range(n):
	(x, y, h) = map(int, input().split())
	l = (x ** 2 + y ** 2) ** (1 / 2)
	if l - h >= r and l + h <= r + d:
		k += 1
print(k)


from math import *
(r, d) = map(int, input().split())
n = int(input())
answ = 0
for i in range(n):
	(x, y, rp) = map(int, input().split())
	if sqrt(x ** 2 + y ** 2) - rp >= r - d and sqrt(x ** 2 + y ** 2) + rp <= r:
		answ += 1
print(answ)


(r, d) = map(int, input().split())
n = int(input())
count = 0
saus = []
for i in range(n):
	saus.append(tuple(map(int, input().split())))
for s in saus:
	(x, y, r_i) = s
	if r_i * 2 > d:
		continue
	dist = (x ** 2 + y ** 2) ** (1 / 2)
	if dist > r or dist < r - d:
		continue
	dist_in_d = dist - (r - d)
	if dist_in_d < r_i:
		continue
	if r - dist >= r_i:
		count += 1
print(count)


import math

def chop():
	return (int(i) for i in input().split())
f = False
(r, d) = chop()
n = int(input())
r2 = r - d
l = 0
for i in range(n):
	(x, y, t) = chop()
	if x ** 2 + y ** 2 <= r ** 2 and x ** 2 + y ** 2 >= r2 ** 2:
		d = math.sqrt(x ** 2 + y ** 2)
		if r >= d + t and r2 <= d - t:
			l += 1
print(l)


read = lambda : tuple(map(int, input().split()))
(r, d) = read()
n = read()[0]
dist = lambda x, y: (x ** 2 + y ** 2) ** 0.5
c = 0
for i in range(n):
	(x, y, ri) = read()
	di = dist(x, y)
	if di >= r - d + ri and di + ri <= r:
		c += 1
print(c)


def isInter(x1, y1, r1, x2, y2, r2):
	r = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
	if r < r1 + r2 and r > abs(r1 - r2):
		return True
	return False

def di(x1, y1, x2, y2):
	return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
(r, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(xi, yi, ri) = map(int, input().split())
	if di(0, 0, xi, yi) >= abs(r - d + ri) and di(0, 0, xi, yi) <= abs(ri - r):
		ans += 1
print(ans)


from math import *

def dist(x, y):
	return sqrt(x ** 2 + y ** 2)
(r, d) = map(int, input().split())
ans = 0
case = int(input())
for i in range(case):
	(x, y, ri) = map(int, input().split())
	dis = dist(x, y)
	if dis >= r - d + ri and dis + ri <= r:
		ans += 1
print(ans)


import math
[all_radius, crust_radius] = map(int, input().split('\n')[0].split(' '))
num_sausage = int(input())
count = 0
for n in range(0, num_sausage):
	(x, y, sausage_radius) = map(int, input().split('\n')[0].split(' '))
	if x ** 2 + y ** 2 >= (all_radius - crust_radius + sausage_radius) ** 2 and x ** 2 + y ** 2 <= (all_radius - sausage_radius) ** 2:
		count += 1
print(count)


from math import sqrt
(r, d) = map(int, input().split())
c = 0
for i in range(int(input())):
	(x, y, rr) = map(int, input().split())
	b = sqrt(x ** 2 + y ** 2)
	if b <= abs(r - rr) and b >= r - d + rr:
		c += 1
print(c)


from math import sqrt

def dist(x1, y1, x2, y2):
	return sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
(r, d) = map(int, input().split())
n = int(input())
res = 0
for i in range(n):
	(x, y, c) = map(int, input().split())
	s = dist(x, y, 0, 0)
	if r - d <= s + c <= r and r - d <= s - c <= r:
		res += 1
print(res)


(r, d) = map(int, input().split())
n = int(input())
xyr = []
for _ in range(n):
	xyr.append(list(map(int, input().split())))
s = 0
for i in xyr:
	g = (i[0] ** 2 + i[1] ** 2) ** 0.5
	if g + i[2] > r:
		continue
	elif g - i[2] < r - d:
		continue
	else:
		s += 1
print(s)


def dist2(pos):
	return pos[0] ** 2 + pos[1] ** 2

def caught(d, rsausage, rpizza, pos):
	if d < 2 * rsausage:
		return False
	mind = rpizza - d + rsausage
	maxd = rpizza - rsausage
	dis = dist2(pos)
	return mind ** 2 <= dis and dis <= maxd ** 2
(r, d) = map(int, input().split())
n = int(input())
ans = 0
for __ in range(n):
	(x, y, ri) = map(int, input().split())
	if caught(d, ri, r, (x, y)):
		ans += 1
print(ans)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(R, D) = map(int, input().split())
N = int(input())
ans = 0
for i in range(N):
	(x, y, r) = map(int, input().split())
	d = math.sqrt(x ** 2 + y ** 2)
	if d - r >= R - D and d + r <= R:
		ans += 1
print(ans)


(r, d) = map(int, input().strip().split(' '))
n = int(input())
k = 0
for i in range(n):
	(x, y, r1) = map(int, input().strip().split(' '))
	dis = pow(x * x + y * y, 0.5)
	if dis + r1 <= r and dis - r1 >= r - d:
		k += 1
print(k)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	(r, d) = LI()
	n = I()
	aa = [LI() for _ in range(n)]
	rr = 0
	for (x, y, ri) in aa:
		k = (x ** 2 + y ** 2) ** 0.5
		if r - d <= k - ri + eps and k + ri - eps <= r:
			rr += 1
	return rr
print(main())


from sys import stdin, stdout
from math import sqrt

def main():
	(rayon, croute) = map(int, stdin.readline().split())
	nbSaus = int(stdin.readline())
	diff = rayon - croute
	total = 0
	for _ in range(nbSaus):
		(x, y, r) = map(int, stdin.readline().split())
		dist = sqrt(x ** 2 + y ** 2)
		distMin = dist - r
		distMax = dist + r
		if distMin >= diff and distMax >= diff and (distMin <= rayon) and (distMax <= rayon):
			total += 1
	stdout.write(str(total))
main()


import math

def In():
	return map(int, input().split())
(r, d) = In()
n = int(input())
count = 0
for i in range(n):
	(x, y, k) = In()
	r2 = math.sqrt(x * x + y * y)
	if math.floor(r2) >= r - d + k and math.ceil(r2) + k <= r:
		count += 1
print(count)


import math
(r, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(x, y, rad) = map(int, input().split())
	s = math.sqrt(x ** 2 + y ** 2)
	if r - d + rad <= s <= r - rad:
		ans += 1
print(ans)


(r, d) = map(int, input().split())
r1 = r - d
r2 = r
n = int(input())
k = 0
for i in range(n):
	(x, y, ri) = map(int, input().split())
	if x * x + y * y >= (r1 + ri) ** 2 and x * x + y * y <= (r2 - ri) ** 2:
		k += 1
print(k)


(R, D) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	d2 = x ** 2 + y ** 2
	if d2 > (R - r) ** 2:
		continue
	a = d2
	b = (R - D + r) ** 2
	ans += a >= b
print(ans)


from math import sqrt
[R, w] = [int(x) for x in input().split()]
n = int(input())
total = 0
for i in range(0, n):
	[x, y, r] = [int(x) for x in input().split()]
	d = sqrt(x * x + y * y)
	if d - r >= R - w and d + r <= R:
		total += 1
print(total)


from math import sqrt
(R, d) = map(int, input().split())
r = R - d
q = int(input())
c = 0
while q:
	(x, y, ri) = map(int, input().split())
	dc = sqrt(x * x + y * y)
	if dc + ri <= R and dc - ri >= r:
		c += 1
	q -= 1
print(c)


(R, d) = map(int, input().split())
n = int(input())
ans = 0
for _ in range(n):
	(x, y, r) = map(int, input().split())
	dist_d = (x * x + y * y) ** 0.5
	if dist_d >= R - d + r and dist_d + r <= R:
		ans += 1
print(ans)


(rmax, rmin) = map(int, input().split())
rmin = rmax - rmin
n = int(input())
rc = 0
for _ in range(n):
	(x, y, r) = map(abs, map(int, input().split()))
	if (x * x + y * y) ** 0.5 - r >= rmin and (x * x + y * y) ** 0.5 + r <= rmax:
		rc += 1
print(rc)


(a, b) = map(int, input().split())
n = int(input())
k = 0
for i in range(n):
	(z, x, y) = map(int, input().split())
	d = (z ** 2 + x ** 2) ** (1 / 2)
	if d + y <= a and d - y >= a - b:
		k = k + 1
print(k)


import sys
(r, d) = map(int, input().split())
n = int(input())

def func(a, b):
	return (a ** 2 + b ** 2) ** 0.5
counter = 0
for i in range(n):
	(xi, yi, ri) = map(int, input().split())
	distance = func(xi, yi)
	if distance - ri < r - d or distance + ri > r:
		continue
	else:
		counter += 1
print(counter)


(r, d) = map(int, input().split())
n = int(input())
c = 0
for _ in range(n):
	(x, y, r_) = map(int, input().split())
	distance = (x * x + y * y) ** 0.5
	if distance + r_ <= r and distance - r_ >= r - d:
		c += 1
print(c)


def find_dist(x1, y1):
	return (x1 ** 2 + y1 ** 2) ** 0.5
(r, d) = map(int, input().split())
n = int(input())
answer = 0
for i in range(n):
	(xi, yi, ri) = map(int, input().split())
	dist = find_dist(xi, yi)
	if dist - ri >= r - d and dist + ri <= r:
		answer += 1
print(answer)


(r, d) = list(map(int, input().split()))
n = int(input())
j = 0
l = r - d
for i in range(n):
	(a, b, g) = list(map(int, input().split()))
	if (abs(a * a) + abs(b * b) >= (l + g) * (l + g)) & (abs(a * a) + abs(b * b) <= (r - g) * (r - g)):
		j += 1
print(j)


(r, d) = map(int, input().split())
n = int(input())
counter = 0
for i in range(n):
	(x, y, r_k) = map(int, input().split())
	if (x ** 2 + y ** 2) ** (1.0 / 2.0) - r_k >= r - d and (x ** 2 + y ** 2) ** (1.0 / 2.0) + r_k <= r:
		counter += 1
print(counter)


from math import sqrt
(r, d) = map(int, input().split())
n = int(input())
an = 0
for i in range(n):
	(x, y, ri) = map(int, input().split())
	d1 = (x ** 2 + y ** 2) ** 0.5
	if d1 >= ri + r - d and d1 + ri <= r:
		an += 1
print(an)


import math

def solve():
	(r, d) = [int(x) for x in input().split(' ')]
	count = 0
	n = int(input())
	for i in range(n):
		(xi, yi, ri) = [int(x) for x in input().split(' ')]
		dis = math.sqrt(xi ** 2 + yi ** 2)
		if r - d + ri <= dis and dis + ri <= r:
			count = count + 1
	return count
print(solve())


(r, d) = map(int, input().split())
kott = r - d
n = int(input())
ans = 0
for i in range(n):
	(x, y, r1) = map(int, input().split())
	k = (y ** 2 + x ** 2) ** 0.5
	if min(r - k, k - kott) >= r1:
		ans += 1
print(ans)


import math
(r, d) = map(int, input().split())
n = int(input())
k = []
res = 0
for i in range(n):
	(s0, s1, s2) = map(int, input().split())
	k.append({'x': s0, 'y': s1, 'r': s2})
for piece in k:
	l = math.sqrt(piece['x'] ** 2 + piece['y'] ** 2)
	if l >= r - d + piece['r'] and l <= r - piece['r']:
		res += 1
print(res)


from math import sqrt
(r, d) = [int(i) for i in input().split()]
innerr = r - d
n = int(input())
count = 0
for i in range(n):
	(a, b, c) = [int(j) for j in input().split()]
	min1 = innerr + c
	max1 = r - c
	if min1 <= sqrt(a ** 2 + b ** 2) <= max1:
		count += 1
print(count)


import math

def main():
	(R, D) = map(int, input().split())
	N = int(input())
	XYR = tuple((tuple(map(int, input().split())) for _ in range(N)))
	ans = 0
	for (x, y, r) in XYR:
		l = math.hypot(x, y)
		if l + r <= R and l - r >= R - D:
			ans += 1
	print(ans)
main()


(R, D) = map(int, input().split())
n = int(input())
cnt = 0
for i in range(0, n):
	(x, y, r) = map(int, input().split())
	d = (x ** 2 + y ** 2) ** 0.5
	if d + r <= R and d - r >= R - D:
		cnt += 1
print(cnt)


import math
(r, d) = map(int, input().split())
n = int(input())
c = 0
for i in range(n):
	(x, y, r1) = map(int, input().split())
	if 2 * r1 <= d:
		d1 = math.sqrt(x * x + y * y)
		if d1 >= r - d + r1 and d1 <= r - r1:
			c += 1
print(c)


(r, d) = tuple(map(int, input().split()))
n = int(input())
ans = 0
for _ in range(n):
	crd = list(map(int, input().split()))
	rs = crd[0] ** 2 + crd[1] ** 2
	if rs <= (r - crd[-1]) ** 2 and rs >= (r - d + crd[-1]) ** 2:
		ans += 1
print(ans)


import math
(r, d) = [int(i) for i in input().strip().split(' ')]
n = int(input().strip())
ans = 0
for i in range(n):
	(x, y, ri) = [int(i) for i in input().strip().split(' ')]
	l = math.sqrt(x * x + y * y)
	if r - d <= l - ri and l + ri <= r:
		ans = ans + 1
print(ans)


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import re

def tup():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
from math import log2, sqrt
(R, D) = tup()
cnt = 0
for _ in range(I()):
	(x, y, r) = tup()
	if sqrt(x ** 2 + y ** 2) + r <= R and sqrt(x ** 2 + y ** 2) >= R - D + r:
		cnt += 1
		debug(sqrt(x ** 2 + y ** 2), r)
print(cnt)


ls = list(map(int, input().split()))
r = ls[0]
d = ls[1]
n = int(input())
ans = 0
for i in range(n):
	l = list(map(int, input().split()))
	x = l[0]
	y = l[1]
	rd = l[2]
	ds = (abs(x) ** 2 + abs(y) ** 2) ** 0.5
	if ds - rd >= r - d and ds + rd <= r:
		ans += 1
print(ans)


(r, d) = map(int, input().split())
n = int(input())
s = 0
for i in range(n):
	(x, y, l) = map(int, input().split())
	if x ** 2 + y ** 2 >= (r - d + l) ** 2 and x ** 2 + y ** 2 <= (r - l) ** 2:
		s += 1
print(s)


import math
(r_pizza, d) = map(int, input().split())
n = int(input())
count = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	distance = math.sqrt(x * x + y * y)
	if distance - r >= r_pizza - d and distance + r <= r_pizza:
		count += 1
print(count)


r = lambda : map(int, input().split())
(rad, d) = r()
n = int(input())
dist_border = rad
dist_start = rad - d
total = 0
for _ in range(n):
	(x, y, rad) = r()
	dist = (x ** 2 + y ** 2) ** 0.5
	if dist - rad >= dist_start and dist + rad <= dist_border:
		total += 1
print(total)


(r, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(x, y, z) = map(int, input().split())
	rr = 0.7
	rr = (x ** 2 + y ** 2) ** (1 / 2.0)
	if rr - z >= r - d and rr + z <= r:
		ans = ans + 1
print(ans)


import math
(r, d) = [int(i) for i in input().split()]
n = int(input())

def process(r, d, x, y, ri):
	center = math.sqrt(x ** 2 + y ** 2)
	return center - ri >= r - d and center + ri <= r
counter = 0
for i in range(n):
	(x, y, ri) = [int(i) for i in input().split()]
	if process(r, d, x, y, ri):
		counter += 1
print(counter)


(r, d) = map(int, input().split())
n = int(input())
cnt = 0
for _ in range(n):
	(xt, yt, rt) = map(int, input().split())
	dt = (xt ** 2 + yt ** 2) ** 0.5
	if dt - rt >= r - d and dt + rt <= r:
		cnt += 1
print(cnt)


import sys, math

def get_dist(x1, y1, x2, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
(r, d) = map(int, sys.stdin.readline().split())
n = int(sys.stdin.readline())
cnt = 0
for _ in range(n):
	(x, y, z) = map(int, sys.stdin.readline().split())
	if get_dist(x, y, 0, 0) >= z + r - d and get_dist(x, y, 0, 0) <= r - z:
		cnt += 1
print(cnt)


(r, d) = list(map(int, input().split()))
count = 0
for i in range(int(input())):
	(x, y, r1) = list(map(int, input().split()))
	k = (x * x + y * y) ** 0.5
	if k - r1 >= r - d and k + r1 <= r:
		count += 1
print(count)


from math import sqrt
(r, di) = map(int, input().split())
dd = r - di
cnt = 0
for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	s = sqrt(x * x + y * y)
	a = s + z
	b = s - z
	if dd <= a <= r and dd <= b <= r:
		cnt += 1
print(cnt)


from math import sqrt

def pizza(r, d, lst):
	count = 0
	for elem in lst:
		p = sqrt(elem[0] * elem[0] + elem[1] * elem[1])
		if p - elem[2] >= r - d and p + elem[2] <= r:
			count += 1
	return count
(R, D) = [int(i) for i in input().split()]
n = int(input())
a = list()
for j in range(n):
	(xi, yi, ri) = [int(t) for t in input().split()]
	a.append([xi, yi, ri])
print(pizza(R, D, a))


(radius, border) = [int(i) for i in input().split(' ')]
n = int(input())

def in_border(x, y, r):
	dist = x * x + y * y
	max_dist = (radius - r) * (radius - r)
	min_dist = (r + radius - border) * (r + radius - border)
	return dist >= min_dist and dist <= max_dist
count = 0
for _ in range(n):
	(x, y, r) = [int(i) for i in input().split(' ')]
	if in_border(x, y, r):
		count += 1
print(count)


(d, r1) = map(float, input().split())
n = int(input())
from sys import stdin
res = 0
for i in range(n):
	(x, y, r2) = map(int, stdin.readline().split())
	item = (x * x + y * y) ** 0.5
	if item - r2 >= d - r1 and d >= item + r2:
		res += 1
print(res)


from typing import List
INF = float('inf')
NINF = float('-inf')

def read_string():
	return input()

def read_string_line():
	return [x for x in input().split(' ')]

def read_int_line():
	return [int(x) for x in input().split(' ')]

def read_int():
	return int(input())

def get_int_arr(s):
	return [int(x) for x in s.split()]

def get_sum(acc, l, r):
	return acc[r] - acc[l]
P = int(1000000000.0 + 7)

def exgcd(x, y):
	if y == 0:
		return (x, 1, 0)
	(g, a, b) = exgcd(y, x % y)
	t = x // y
	return (g, b, a - t * b)

def inv(x):
	(g, a, b) = exgcd(x, P)
	return a

def calc_acc(arr):
	ans = [0]
	for a in arr:
		ans.append(a + ans[-1])
	return ans
lines: List[str] = [*open(0)]
(r, d) = get_int_arr(lines[0])
n = int(lines[1])
eps = 1e-08
ans = 0
for ti in range(n):
	(x, y, k) = get_int_arr(lines[ti + 2])
	dist = (x ** 2 + y ** 2) ** 0.5
	if r - d - eps <= dist - k and dist + k <= r + eps:
		ans += 1
print(ans)


import math
(r, d) = map(int, input().strip().split(' '))
n = int(input())
rs = r - d
c = 0
for i in range(n):
	(x, y, rad) = map(int, input().strip().split(' '))
	p = math.sqrt(x * x + y * y)
	if p - rad >= rs and p + rad <= r:
		c += 1
print(c)


(R, d) = list(map(int, input().split(' ')))
n = int(input())
caught = 0
for i in range(n):
	(x, y, r) = list(map(int, input().split(' ')))
	if (R - d + r) * (R - d + r) <= x * x + y * y and x * x + y * y <= (R - r) * (R - r):
		caught += 1
print(caught)


from math import sqrt

def read_int(string):
	return tuple(map(int, string.split()))

def dist(circle):
	return sqrt(circle[0] ** 2 + circle[1] ** 2)

def main():
	(r, d) = read_int(input())
	(inner_radius, outer_radius) = (r - d, r)
	n = int(input())
	circles = [read_int(input()) for _ in range(n)]
	count = 0
	for circle in circles:
		inner_edge = dist(circle) - circle[2]
		outer_edge = dist(circle) + circle[2]
		if inner_edge >= inner_radius and outer_edge <= outer_radius:
			count += 1
	print(count)
main()


import math
(r, d) = map(int, input().split())
s = int(input())
cnt = 0
for i in range(s):
	(a, b, c) = map(int, input().split())
	if c + math.sqrt(a * a + b * b) <= r and math.sqrt(a * a + b * b) - c >= r - d:
		cnt += 1
print(cnt)


mas = list(map(int, input().split()))
r = mas[0]
d = mas[1]
mas = list(map(int, input().split()))
t = mas[0]
n = 0
for j in range(t):
	mas = list(map(int, input().split()))
	xj = mas[0]
	yj = mas[1]
	rj = mas[2]
	s2 = xj ** 2 + yj ** 2
	if s2 >= (r - d) ** 2 and s2 <= r ** 2 and (2 * rj <= d) and (s2 >= (r - d + rj) ** 2) and (s2 <= (r - rj) ** 2):
		n += 1
print(n)


(r, d) = map(int, input().split())
n = int(input())
s = 0
for _ in [0] * n:
	(x, y, z) = map(int, input().split())
	if z > r:
		continue
	w = x * x + y * y
	s += (r - z) ** 2 >= w >= (r - d + z) ** 2
print(s)


(r, d) = map(int, input().split())
n = int(input())
e = 0
for i in range(n):
	(x, y, rq) = map(int, input().split())
	if abs((x * x + y * y) ** 0.5) - rq >= r - d and abs((x * x + y * y) ** 0.5) + rq <= r:
		e += 1
print(e)


(r, d) = map(int, input().split())
n = int(input())
circles = [list(map(int, input().split())) for i in range(n)]
t = 0
for i in range(n):
	(x, y, rr) = circles[i]
	if (x * x + y * y) ** 0.5 - rr >= r - d and (x * x + y * y) ** 0.5 + rr <= r:
		t += 1
print(t)


import math
(r, d) = map(int, input().split())
sum = 0
for _ in range(int(input())):
	(xi, yi, ri) = map(int, input().split())
	if r - d <= math.sqrt(xi * xi + yi * yi) + ri <= r and r - d <= math.sqrt(xi * xi + yi * yi) - ri <= r:
		sum += 1
print(sum)


(r, d) = map(int, input().strip().split())
n = int(input().strip())
mn = r - d
mx = r
c = 0
for _ in range(n):
	(xs, ys, rs) = map(int, input().strip().split())
	dis = (xs * xs + ys * ys) ** 0.5
	d1 = dis - rs
	d2 = dis + rs
	if d1 >= mn and d2 <= mx:
		c += 1
print(c, end='')


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			high = mid
		else:
			low = mid + 1
	return low

def check(time, m, assistants):
	summ = 0
	for p in assistants:
		time_needed_with_rest = p[0] * p[1] + p[2]
		time_needed_without_rest = p[0]
		baloons_can_be_inflated = p[1]
		summ += time // time_needed_with_rest * baloons_can_be_inflated
		ntime = time % time_needed_with_rest
		summ += min(ntime // time_needed_without_rest, baloons_can_be_inflated)
	return summ >= m
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	(r, d) = read()
	n = int(input())
	count = 0
	for i in range(n):
		(x, y, radius) = read()
		dist = (x ** 2 + y ** 2) ** 0.5
		if dist - radius >= r - d and dist + radius <= r:
			count += 1
	print(count)
for _ in range(1):
	solve()


import math
(r, d) = map(int, input().split())
n = int(input())
l = r - d
k = 0
for i in range(n):
	(x, y, ri) = map(int, input().split())
	p = math.sqrt(x * x + y * y)
	if p - ri >= l and p + ri <= r:
		k += 1
print(k)


(radius, crust) = [int(x) for x in input().split()]
cases = int(input())
counter = 0
for i in range(cases):
	(x, y, r) = [int(x) for x in input().split()]
	if (x ** 2 + y ** 2) ** (1 / 2) + r <= radius:
		if (x ** 2 + y ** 2) ** (1 / 2) >= radius - crust + r:
			counter += 1
print(counter)


(r, d) = [int(x) for x in input().split()]
n = int(input())
l = []
cont = 0
for i in range(n):
	l.append([abs(int(x)) for x in input().split()])
b = r - d
for i in l:
	a = i[0] * i[0] + i[1] * i[1]
	t1 = (r - i[2]) * (r - i[2])
	t2 = (i[2] + r - d) * (i[2] + r - d)
	if a >= t2 and a <= t1:
		cont += 1
print(cont)


(r, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(x, y, rc) = map(int, input().split())
	dis = pow(x * x + y * y, 0.5)
	if r - d + rc <= dis <= r - rc:
		ans = ans + 1
print(ans, end='')


(r, d) = list(map(int, input().split()))
n = int(input())
rs = [list(map(int, input().split())) for i in range(n)]

def dist(x1, y1, x2, y2):
	a = (x1 - x2) ** 2 + (y1 - y2) ** 2
	b = a ** 0.5
	if int(b) ** 2 == a:
		return int(b)
	if int(b + 1) ** 2 == a:
		return int(b + 1)
	return b

def f(c):
	dis = dist(0, 0, c[0], c[1])
	if dis - c[2] < r - d:
		return False
	if dis + c[2] > r:
		return False
	return True
x = 0
for i in range(n):
	if f(rs[i]):
		x += 1
print(x)


import math
(r, d) = map(int, input().split())
result = 0
for i in range(int(input())):
	(x, y, ri) = map(int, input().split())
	dist = math.sqrt(x ** 2 + y ** 2)
	if r - d <= dist - ri and dist + ri <= r:
		result += 1
print(result)


(r1, d) = map(int, input().split())
(r2, k) = (r1 - d, 0)
for _ in range(int(input())):
	(x, y, r) = map(int, input().split())
	s = (x ** 2 + y ** 2) ** 0.5
	if s - r >= r2 and s + r <= r1:
		k += 1
print(k)


from math import sqrt
(r, d) = map(int, input().split())
n = int(input())
cnt = 0
for i in range(n):
	(x, y, ri) = map(int, input().split())
	a = sqrt(x ** 2 + y ** 2) - ri
	b = a + 2 * ri
	if a >= r - d and b <= r:
		cnt += 1
print(cnt)


alph = 'abcdefghijklmnopqrstuvwxyz'
(R, d) = map(int, input().split())
n = int(input())
E = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	p = (x ** 2 + y ** 2) ** 0.5
	if p >= R - d + r and p <= R - r:
		E += 1
print(E)


(r1, d1) = map(int, input().split())
n = int(input())
sum = 0
for i in range(n):
	(x, y, r) = map(int, input().split())
	R = (x ** 2 + y ** 2) ** 0.5
	if R - r >= r1 - d1 and R + r <= r1:
		sum += 1
print(sum)


import math
(R, d) = map(int, input().split())
n = int(input())
c = 0
while n:
	n -= 1
	(x, y, r) = map(int, input().split())
	if R - d + r <= math.sqrt(x ** 2 + y ** 2) <= R - r:
		c += 1
	else:
		pass
print(c)


(r, d) = map(int, input().split())
d = r - d
n = int(input())
cnt = 0
for _ in range(n):
	(x, y, z) = map(int, input().split())
	if (d + z) ** 2 <= x * x + y * y <= (r - z) ** 2:
		cnt += 1
print(cnt)


arr = list(map(int, input().split()))
n = int(input())
res = 0
rp = arr[0]
d = arr[1]

def distanceFromOrigin(x, y):
	return pow(pow(x, 2) + pow(y, 2), 0.5)
count = 0
for i in range(n):
	query = list(map(int, input().split()))
	x = query[0]
	y = query[1]
	r = query[2]
	disLow = distanceFromOrigin(x, y) - r
	disHigh = distanceFromOrigin(x, y) + r
	if disLow >= rp - d and disHigh <= rp:
		count += 1
print(count)


def sqr(x):
	return x * x
(r, d) = map(int, input().split())
(r2, d2) = (r * r, d * d)
n = int(input())
cnt = 0
for i in range(n):
	(x, y, ri) = map(int, input().split())
	if x * x + y * y >= sqr(r - d + ri) and x * x + y * y <= sqr(r - ri):
		cnt += 1
print(cnt)


(X, Sum) = (list(map(int, input().split())), 0)
for i in range(int(input())):
	Temp = list(map(int, input().split()))
	First = Temp[0] ** 2 + Temp[1] ** 2
	if First in range((X[0] - X[1] + Temp[-1]) ** 2, (X[0] - Temp[-1]) ** 2 + 1):
		Sum += 1
print(Sum)


import sys
from math import sqrt
input = sys.stdin.readline
(R, d) = map(int, input().split())
res = 0
for i in range(int(input())):
	(x, y, r) = map(int, input().split())
	dd = sqrt(abs(x) ** 2 + abs(y) ** 2)
	if dd <= abs(R - r) and dd >= R - d + r:
		res += 1
print(res)


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True
(r, d) = mi()
n = ii()
ans = 0
for i in range(n):
	(x, y, rc) = mi()
	if 2 * rc <= d and r - d + rc <= math.sqrt(x ** 2 + y ** 2) and (math.sqrt(x ** 2 + y ** 2) <= r - rc):
		ans += 1
print(ans)


I = lambda : map(int, input().split())
(r, d) = I()
n = int(input())
ans = 0
for i in range(n):
	(sx, sy, sr) = I()
	sd = (sx ** 2 + sy ** 2) ** 0.5
	if sd - sr >= r - d and sd + sr <= r:
		ans += 1
print(ans)


(r, d) = map(int, input().split())
res = 0
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	x = (a ** 2 + b ** 2) ** 0.5
	if x + c <= r and x - c >= r - d:
		res += 1
print(res)


import math
pr = lambda a, b: math.sqrt(a ** 2 + b ** 2)
(r, d) = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
	(x, y, z) = map(float, input().split())
	if r - d <= pr(x, y) - z and r >= pr(x, y) + z:
		ans += 1
print(ans)


(radius, width) = input().split()
(radius, width) = (int(radius), int(width))
sausages = int(input())
count = 0
for _ in range(sausages):
	(x, y, r) = input().split()
	(x, y, r) = (int(x), int(y), int(r))
	dist = (x ** 2 + y ** 2) ** 0.5
	if dist - r >= radius - width and dist + r <= radius:
		count += 1
print(count)


import math
(r, d) = list(map(int, input().split()))
n = int(input())
incrust = 0
for i in range(n):
	(xi, yi, ri) = list(map(int, input().split()))
	p = math.sqrt(xi * xi + yi * yi)
	if p - ri >= r - d and p + ri <= r:
		incrust = incrust + 1
print(incrust)