CodeEff/ECCO huggingface dataset:
# Original solution
case = 0
while True:
  case += 1
  W = int(eval(input()))
  if (W == 0):
    break
  N = int(eval(input()))
  vl = [0]
  wl = [0]
  for i in range(N):
    (v,w) = tuple(map(int,input().split(",")))
    vl.append(v)
    wl.append(w)
  dp = [[0 for i in range(W+1)] for j in range(N+1)]
  for i in range(1,N+1):
    for j in range(1,W+1):
      if j >= wl[i]:
        dp[i][j] = max(dp[i-1][j], dp[i][j-1], dp[i-1][j-wl[i]] + vl[i])
      else:
        dp[i][j] = max(dp[i-1][j], dp[i][j-1])
  print(("Case " + str(case) + ":"))
  print((dp[N][W]))
  for i in range(W+1):
    if dp[N][i] == dp[N][W]:
      print(i)
      break


# Optimized solution
"""
0-1ナップザック
dp[i][j]...i個目までの宝で重さjの時の価値の最大
wi = wlst[i]...i個目の重さ
vi = vlst[i]...i個目の価値
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi)  (wi <= j)
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])                          (wi >  j)
"""


def main():
  case = 0

  while True:
    w = int(eval(input()))
    if not w:
      break
  
    case += 1
  
    n = int(eval(input()))
  
    vlst = [0]
    wlst = [0]
  
    for _ in range(n):
      vin, win = list(map(int, input().split(",")))
      vlst.append(vin)
      wlst.append(win)

    dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
    
    for i in range(1, n + 1):
      vi, wi = vlst[i], wlst[i]
      dpi = dp[i]
      dpim = dp[i - 1]
      for j in range(1, w + 1):
        if j >= wi:
          dpi[j] = max(dpim[j], dpi[j - 1], dpim[j - wi] + vi)
        else:
          dpi[j] = max(dpim[j], dpi[j - 1])
  
    print(("Case " + str(case) + ":"))
    print((dp[n][w]))

    for i in range(w, -1, -1):
      if dp[n][i] != dp[n][w]:
        print((i + 1))
        break

main()
# Original solution
"""
0-1ナップザック
dp[i][j]...i個目までの宝で重さjの時の価値の最大
wi = wlst[i]...i個目の重さ
vi = vlst[i]...i個目の価値
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi)  (wi <= j)
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])                          (wi >  j)
"""


def main():
  case = 0

  while True:
    w = int(eval(input()))
    if not w:
      break
  
    case += 1
  
    n = int(eval(input()))
  
    vlst = [0]
    wlst = [0]
  
    for _ in range(n):
      vin, win = list(map(int, input().split(",")))
      vlst.append(vin)
      wlst.append(win)

    dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
    
    for i in range(1, n + 1):
      vi, wi = vlst[i], wlst[i]
      dpi = dp[i]
      dpim = dp[i - 1]
      for j in range(1, w + 1):
        if j >= wi:
          dpi[j] = max(dpim[j], dpi[j - 1], dpim[j - wi] + vi)
        else:
          dpi[j] = max(dpim[j], dpi[j - 1])
  
    print(("Case " + str(case) + ":"))
    print((dp[n][w]))

    for i in range(w, -1, -1):
      if dp[n][i] != dp[n][w]:
        print((i + 1))
        break

main()


# Optimized solution
"""
0-1ナップザック
wi = wlst[i]...i個目の重さ
vi = vlst[i]...i個目の価値

2次元

dp[i][j]...i個目までの宝で重さjの時の価値の最大
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi)  (wi <= j)
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])                          (wi >  j)

or

dp[j]...重さjの時の価値の最大
temp...1つ前のdp
dp[j] = max(dp[j], dp[j - 1], temp[j - wi] + vi)  (wi <= j)
dp[j] = max(dp[j], dp[j - 1])                     (wi >  j)

"""

INF = 10 ** 20

def main():
  case = 0

  while True:
    w = int(eval(input()))
    if not w:
      break
  
    case += 1
  
    n = int(eval(input()))
  
    vlst = [0]
    wlst = [0]
  
    for _ in range(n):
      vin, win = list(map(int, input().split(",")))
      vlst.append(vin)
      wlst.append(win)

    dp = [0 for _ in range(w + 1)]
    
    for i in range(1, n + 1):
      vi, wi = vlst[i], wlst[i]
      temp = dp[:]
      for j in range(1, w + 1):
        if j >= wi:
          dp[j] = max(dp[j], dp[j - 1], temp[j - wi] + vi)
        else:
          dp[j] = max(dp[j], dp[j - 1])
  
    print(("Case " + str(case) + ":"))
    print((dp[w]))
    print((dp.index(dp[w])))
main()
# Original solution
"""
0-1ナップザック
wi = wlst[i]...i個目の重さ
vi = vlst[i]...i個目の価値

2次元

dp[i][j]...i個目までの宝で重さjの時の価値の最大
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi)  (wi <= j)
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])                          (wi >  j)

or

dp[j]...重さjの時の価値の最大
temp...1つ前のdp
dp[j] = max(dp[j], dp[j - 1], temp[j - wi] + vi)  (wi <= j)
dp[j] = max(dp[j], dp[j - 1])                     (wi >  j)

"""

INF = 10 ** 20

def main():
  case = 0

  while True:
    w = int(eval(input()))
    if not w:
      break
  
    case += 1
  
    n = int(eval(input()))
  
    vlst = [0]
    wlst = [0]
  
    for _ in range(n):
      vin, win = list(map(int, input().split(",")))
      vlst.append(vin)
      wlst.append(win)

    dp = [0 for _ in range(w + 1)]
    
    for i in range(1, n + 1):
      vi, wi = vlst[i], wlst[i]
      temp = dp[:]
      for j in range(1, w + 1):
        if j >= wi:
          dp[j] = max(dp[j], dp[j - 1], temp[j - wi] + vi)
        else:
          dp[j] = max(dp[j], dp[j - 1])
  
    print(("Case " + str(case) + ":"))
    print((dp[w]))
    print((dp.index(dp[w])))
main()



# Optimized solution
"""
0-1ナップザック
wi...i個目の重さ
vi...i個目の価値

2次元

dp[i][j]...i個目までの宝で重さjの時の価値の最大
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi)  (wi <= j)
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])                          (wi >  j)


1次元

dp[j]...重さjの時の価値の最大
dp[j] = max(dp[j], dp[j - wi] + vi)  (wi <= j <= w)

wi <= j <= wについて更新(j < wiについては変化が無いため更新不要)
前から更新すると更新した結果を使って更新してしまうため後ろから更新
"""

INF = 10 ** 20

def main():
  case = 0

  while True:
    w = int(eval(input()))
    if not w:
      break
  
    case += 1
  
    n = int(eval(input()))
  
    dp = [0 for _ in range(w + 1)]
    
    for i in range(1, n + 1):
      vi, wi = list(map(int, input().split(",")))
      for j in range(w, wi - 1, -1):
        dp[j] = max(dp[j], dp[j - wi] + vi)
  
    print(("Case " + str(case) + ":"))
    print((dp[w]))
    print((dp.index(dp[w])))
main()
# Original solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import *
from sys import *

def solve(n,w):
  lp,lw = [],[]
  for i in range(n):
    s = list(map(int, input().split(",")))
    lp.append(s[0])
    lw.append(s[1])
  mp = mw = 0
  for e in product([0,1],repeat=n):
    cw = sum([ lw[i] for i in range(len(e)) if e[i] ])
    cp = sum([ lp[i] for i in range(len(e)) if e[i] ])
    
    if cp == mp and mw > cw: mw = cw
    if w >= cw and cp > mp: mp = cp; mw = cw
  print(mp)
  print(mw)

case = 0
while True:
  case += 1
  w = int(input())
  if w == 0: break
  n = int(input())
  print("Case %d:" % (case))
  solve(n,w)

# Optimized solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import *
from sys import *

def solve(n,w):
  lp,lw = [],[]
  for i in range(n):
    s = list(map(int, input().split(",")))
    lp.append(s[0])
    lw.append(s[1])
  c = [-1]*(w+1)
  c[0] = 0
  for i in range(n):
    for j in reversed(range(w)):
      if c[j] == -1 or j+lw[i] > w : continue
      c[j+lw[i]] = max( c[j]+lp[i], c[j+lw[i]] )
  print(max(c))
  print(c.index(max(c)))

case = 1
while True:
  w = int(input())
  if w == 0: break
  n = int(input())
  print("Case %d:" % (case))
  solve(n,w)
  case += 1
# Original solution
cnt=0
while True:
    cnt+=1
    W=int(eval(input()))
    if W==0:
        break
    n=int(eval(input()))
    dp=[0]*(W+1)
    for i in range(n):
        v,w=list(map(int,input().split(',')))
        for j in range(W,w-1,-1):
            dp[j]=max(dp[j],dp[j-w]+v)
    wgt=0
    for i in range(W+1):
        if max(dp)==dp[i]:
            wgt=i
            break
    print(("Case {0}:".format(cnt)))
    print((max(dp)))
    print(wgt)

# Optimized solution
cnt=0
while True:
    cnt+=1
    W=int(eval(input()))
    if W==0:
        break
    n=int(eval(input()))
    dp=[0]*(W+1)
    for i in range(n):
        v,w=list(map(int,input().split(',')))
        for j in range(W,w-1,-1):
            dp[j]=max(dp[j],dp[j-w]+v)
    wgt=0
    md=max(dp)
    for i in range(W+1):
        if md==dp[i]:
            wgt=i
            break
    print(("Case {0}:".format(cnt)))
    print(md)
    print(wgt)
# Original solution
# AOJ 0042 A Thief
# Python3 2018.6.22 bal4u

MAX = 1003

for cno in range(1, 100):
	lim = int(input())
	if lim == 0: break
	print("Case ", cno, ":", sep='')
	N = int(input())
	vw = [(0, 0)]
	for i in range(N):
		v, w = list(map(int, input().split(',')))
		vw.append((v, w))

	V = [[0 for j in range(MAX)] for i in range(2)]
	W = [[0 for j in range(MAX)] for i in range(2)]		
	k1, k2 = 0, 1
	for i in range(1, N+1):
		for j in range(1, lim+1):
			v, w = vw[i]
			if w > j:
				V[k2][j] = V[k1][j]
				W[k2][j] = W[k1][j]
			else:
				d = j - w
				if V[k1][d] + v >= V[k1][j]:
					V[k2][j] = V[k1][d] + v
					W[k2][j] = W[k1][d] + w
				else:
					V[k2][j] = V[k1][j]
					W[k2][j] = W[k1][j]
		k1, k2 = k2, k1
	print(V[k1][lim], W[k1][lim], sep='\n')


# Optimized solution
# AOJ 0042 A Thief
# Python3 2018.6.22 bal4u

MAX = 1003

for cno in range(1, 100):
	lim = int(input())
	if lim == 0: break
	print("Case ", cno, ":", sep='')
	N = int(input())
	V = [[0 for j in range(MAX)] for i in range(2)]
	W = [[0 for j in range(MAX)] for i in range(2)]		
	k1, k2 = 0, 1
	for i in range(1, N+1):
		v, w = map(int, input().split(','))
		for j in range(1, w):
			V[k2][j] = V[k1][j]
			W[k2][j] = W[k1][j]
		for j in range(w, lim+1):
			d = j - w
			if V[k1][d] + v >= V[k1][j]:
				V[k2][j] = V[k1][d] + v
				W[k2][j] = W[k1][d] + w
			else:
				V[k2][j] = V[k1][j]
				W[k2][j] = W[k1][j]
		k1, k2 = k2, k1
	print(V[k1][lim], W[k1][lim], sep='\n')
# Original solution
c =0
while True:
    W = eval(input())
    if W==0: break
    dt = [0]*1001
    c +=1
    N = eval(input())
    m = 0
    n = 0
    for i in range(N):
        p,w = eval(input())
        for w0 in range(W+1)[::-1]:
            p0 = dt[w0]
            if w0==0 or p0!=0:
                w1 = w0+w
                p1 = p0+p
                if w1<=W and dt[w1]<p1: dt[w1]=p1
    m = max(dt)
    n = dt.index(m)
    print("Case {}:".format(c))
    print(m)
    print(n)

# Optimized solution
def f():
    p,w = eval(input())
    for w0 in R[w:]:
        w1,p1 = w0+w,dt[w0]+p
        if dt[w1]<p1: dt[w1]=p1
    return

c = 0
while 1:
    W = eval(input())
    if W==0: break
    R = list(range(W+1))[::-1]
    dt = [0]*1001
    c += 1
    N = eval(input())
    for i in range(N): f()
    m = max(dt)
    n = dt.index(m)
    print("Case {}:\n{}\n{}".format(c,m,n))
# Original solution
n, d = list(map(int, input().split()))
xy = []
for i in range(n):
  a, b = list(map(int, input().split()))
  xy.append([a, b])
 
count = [xi**2 + yi**2 <= d**2 for xi, yi in xy]
 
print((sum(count)))

# Optimized solution
n, d = list(map(int, input().split()))
xy = 0
for i in range(n):
  xi, yi = list(map(int, input().split()))
  xy += xi**2 + yi**2 <= d**2
 
print(xy)
# Original solution
from math import sqrt

def main():

  N, D = list(map(int, input().split()))
  P = [list(map(int, input().split())) for i in range(N)]
  ans = 0
  for i in range(N):
    if sqrt(P[i][0]**2 + P[i][1]**2) <= D:
      ans += 1
  print(ans)
main()

# Optimized solution
def main():
  from math import sqrt
  N, D = list(map(int, input().split()))
  P = [list(map(int, input().split())) for i in range(N)]
  ans = 0
  for i in range(N):
    if sqrt(P[i][0]**2 + P[i][1]**2) <= D:
      ans += 1
  print(ans)
main()
# Original solution
def main():
  from math import sqrt
  N, D = list(map(int, input().split()))
  P = [list(map(int, input().split())) for i in range(N)]
  ans = 0
  for i in range(N):
    if sqrt(P[i][0]**2 + P[i][1]**2) <= D:
      ans += 1
  print(ans)
main()

# Optimized solution
def main():
  N, D = list(map(int, input().split()))
  ans = 0
  for i in range(N):
    x, y = list(map(int, input().split()))
    if x**2 + y**2 <= D**2:
      ans += 1
  print(ans)
main()
# Original solution
n,d = list(map(int, input().split()))

dotCount = 0
for i in range(n):
  #print(i)
  x,y = list(map(int, input().split()))
  if d*d >= x*x + y*y:
    dotCount += 1
print(dotCount)


# Optimized solution
n,d = list(map(int, input().split()))

dotCount = 0
square_d = d*d
for i in range(n):
  #print(i)
  x,y = list(map(int, input().split()))
  if square_d >= x*x + y*y:
    dotCount += 1
print(dotCount)
# Original solution
n,d = list(map(int, input().split()))

dotCount = 0
square_d = d*d
for i in range(n):
  #print(i)
  x,y = list(map(int, input().split()))
  if square_d >= x**2 + y**2:
    dotCount += 1
    
print(dotCount)


# Optimized solution
coordinate_number,distance = list(map(int, input().split()))

within_distance = 0
square_distance = distance*distance
for i in range(coordinate_number):
  x,y = list(map(int, input().split()))
  if square_distance >= x*x + y*y:
    within_distance += 1

print(within_distance)
# Original solution
# B - Distance
from math import sqrt


def main():
    N, D, *XY = list(map(int, open(0).read().split()))
    res = sum(sqrt(x ** 2 + y ** 2) <= D for x, y in zip(*[iter(XY)] * 2))
    print(res)


if __name__ == "__main__":
    main()


# Optimized solution
# B - Distance
def main():
    N, D, *XY = list(map(int, open(0).read().split()))
    res = sum(x ** 2 + y ** 2 <= D ** 2 for x, y in zip(*[iter(XY)] * 2))
    print(res)


if __name__ == "__main__":
    main()
# Original solution
import math
n,d = list(map(int,input().split()))
cnt = 0

for i in range(n):
  x,y= list(map(int,input().split()))
  if math.sqrt(x**2+y**2) <= d:
    cnt += 1
print(cnt)

# Optimized solution
n,d = list(map(int,input().split()))

cnt = 0
for i in range(n):
  
  x,y = list(map(int,input().split()))
  if (x**2 + y**2)**0.5 <= d:
    cnt += 1
print(cnt)
# Original solution
n,d = list(map(int, input().split()))
c=0
for i in range(n):
  x,y = list(map(int, input().split()))
  if x ** 2 + y ** 2<= d ** 2:
    c += 1
print(c)

# Optimized solution
n,d = list(map(int, input().split()))
c=0
for i in range(n):
  x,y = list(map(int, input().split()))
  if x * x + y * y <= d * d:
    c += 1
print(c)
# Original solution
def resolve():
    N, D = list(map(int, input().split()))
    P = [list(map(int, input().split())) for x in range(N)]

    cnt = 0
    for p in P:
        d = (p[0] ** 2 + p[1] ** 2) ** 0.5
        if d <= D:
            cnt += 1

    print(cnt)
resolve()

# Optimized solution
def resolve():
    N, D = list(map(int, input().split()))

    cnt = 0
    for n in range(N):
        x, y = list(map(int, input().split()))
        d = (x ** 2 + y ** 2) ** 0.5
        if d <= D:
            cnt += 1

    print(cnt)
resolve()
# Original solution
n, d = list(map(int,input().split()))
ans =0
for i in range(n):
    x, y = list(map(int,input().split()))
    if pow((x**2+y**2),0.5)<=d:
        ans += 1

print(ans)

# Optimized solution
import sys

N, D = list(map(int, input().split()))
cnt = 0
for s in sys.stdin.readlines():
    x, y = list(map(int, s.split()))
    d = pow(x, 2) + pow(y, 2)
    cnt += (d <= pow(D, 2))
print(cnt)
# Original solution
N,D=list(map(int,input().split()))
a=0
d=D**2
for i in range(N):
    x,y=list(map(int,input().split()))
    if x**2+y**2<=d:
        a+=1
print(a)


# Optimized solution
import sys
def input():
    return sys.stdin.readline()[:-1]
N,D=list(map(int,input().split()))
a=0
d=D**2
for i in range(N):
    x,y=list(map(int,input().split()))
    if x**2+y**2<=d:
        a+=1
print(a)
# Original solution
import math

N,D =[int(x) for x in input().split()]

X = []
Y = []

for i in range(N):
    x,y = [int(x) for x in input().split()]
    X.append(x)
    Y.append(y)

ans = 0

for i in range(N):
    r = math.sqrt(X[i] ** 2 + Y[i] ** 2)
    if r <= D:
        ans += 1

print(ans)

# Optimized solution
N,D =[int(x) for x in input().split()]

ans = 0

for i in range(N):
    x,y = [int(x) for x in input().split()]
    if x * x + y * y <= D * D:
        ans += 1

print(ans)
# Original solution
n,d=list(map(int,input().split()))
print((sum(eval("(("+input().replace(" ",")**2+(")+")**2)**0.5<=d") for _ in range(n))))

# Optimized solution
n,d=list(map(int,input().split()))
print((sum(eval("(("+input().replace(" ",")**2+(")+")**2)")**0.5<=d for _ in range(n))))
# Original solution
N, D = list(map(int, input().split()))
count = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    if (a**2 + b**2) <= D**2:
        count += 1
print(count)


# Optimized solution
N, D = list(map(int, input().split()))
count = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    if (a*a + b*b) <= D*D:
        count += 1
print(count)
# Original solution
import math

N, D = list(map(int, input().split()))
X_Y = []
for i in range(N):
    X_Y.append(list(map(int, input().split())))
    
ans = 0
for n in range(N):
  x, y = X_Y[n]
  if(math.sqrt(x**2 + y**2) <= D): ans += 1

print(ans)

# Optimized solution
N, D = list(map(int, input().split()))
X_Y = []
for i in range(N):
    X_Y.append(list(map(int, input().split())))
    
ans = 0
for n in range(N):
  x, y = X_Y[n]
  # ルートを計算すると計算誤差が生じるので、距離の2乗を比較する
  if(x**2 + y**2 <= D*D): ans += 1

print(ans)
# Original solution
N, D = list(map(int, input().split()))

ans = 0
for i in range(N):
    x, y = list(map(int, input().split()))
    dist = pow((x * x + y * y), 0.5)
    # print(dist)
    if dist <= D:
        ans += 1

print(ans)


# Optimized solution
N, D = list(map(int, input().split()))

ans = 0
for i in range(N):
    x, y = list(map(int, input().split()))
    # dist = pow((x * x + y * y), 0.5)
    dist = (x * x + y * y)
    
    # print(dist)
    if dist <= D*D:
        ans += 1

print(ans)
# Original solution
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
import math
n,d = list(map(int, input().split()))

ans = 0

for i in range(n):
    x, y = list(map(int, input().split()))
    kyori = math.sqrt(x*x+y*y)
    if kyori <= d:
        ans+=1
print(ans)



# Optimized solution
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]


n, d = list(map(int, input().split()))
ans = 0
for i in range(n):
    x, y = list(map(int, input().split()))
    if x*x + y*y <= d*d:
        ans+=1
print(ans)
# Original solution
n, d=list(map(int, input().split()))
cnt=0

for i in range(n):
    x, y=list(map(int, input().split()))
    tmp=(x**2 +y**2)**0.5
    if tmp<=d:
        cnt+=1

print(cnt)

# Optimized solution
n, d=list(map(int, input().split()))
cnt=0

for i in range(n):
    x, y=list(map(int, input().split()))
    tmp=x**2 + y**2
    if tmp<=d**2:
        cnt+=1

print(cnt)
# Original solution
N, D = [int(v) for v in input().split()]

ans = 0
for _ in range(N):
    x, y = [int(v) for v in input().split()]
    if (x**2 + y**2) ** 0.5 <= D:
        ans += 1

print(ans)

# Optimized solution
N, D = [int(v) for v in input().split()]
D = D*D
ans = 0
for _ in range(N):
    x, y = [int(v) for v in input().split()]
    if (x**2 + y**2) <= D:
        ans += 1

print(ans)
# Original solution
from decimal import Decimal

n, d = list(map(int, input().split()))
res = 0
for _ in range(n):
    x, y = list(map(Decimal, input().split()))
    if (x**2 + y**2).sqrt() <= d:
        res += 1
print(res)


# Optimized solution
n, d = list(map(int, input().split()))
res = 0
for _ in range(n):
    x, y = list(map(int, input().split()))
    if (x**2 + y**2)**0.5 <= d:
        res += 1
print(res)
# Original solution
n, d = list(map(int, input().split()))
res = 0
for _ in range(n):
    x, y = list(map(int, input().split()))
    if (x**2 + y**2)**0.5 <= d:
        res += 1
print(res)


# Optimized solution
n, d = list(map(int, input().split()))
res = 0
for _ in range(n):
    x, y = list(map(int, input().split()))
    if x**2 + y**2 <= d**2:
        res += 1
print(res)
# Original solution
N, D = list(map(int, input().split()))
P = [tuple(map(int, input().split())) for i in range(N)]

ans = 0
for p, q in P:
    if p * p + q * q <= D * D:
        ans += 1
print(ans)


# Optimized solution
N, D = list(map(int, input().split()))
P = [tuple(map(int, input().split())) for i in range(N)]

print((sum([p * p + q * q <= D * D for p, q in P])))
# Original solution
#  Author: Amey Bhavsar
#  ID: bhavsar
#  IDE: Geany/Ubuntu
#  Platform: AtCoder Beginner Contest 174
from math import sqrt, floor, pi, cos, sin, log, log2



#  n=map(int,input().split())
n,m=list(map(int,input().split()))
ans = 0
for i in range(n):
	x,y=list(map(int,input().split()))
	if (sqrt(x*x + y*y) <= m):
		ans+=1
print(ans)
	

#  a=list(map(int,input().split()))
#  mat = []
#  for i in range(n):
	#  r = input()
	#  r = list(map(int,input().split()))
	#  mat.append(r)



# Optimized solution
n, d = list(map(int, input().split()))
d *= d
cnt = 0
for i in range(n):
	x,y=list(map(int,input().split()))
	if (x*x + y*y <= d): cnt+=1
print(cnt)
# Original solution
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力を取得
N, D = list(map(int, input().split()))
X, Y = [], []
for n in range(N):
    X_n, Y_n = list(map(int, input().split()))
    X.append(X_n)
    Y.append(Y_n)

# 求解処理


def get_distance(p: int, q: int) -> float:
    return math.sqrt(math.pow(p, 2) + math.pow(q, 2))


ans = 0
for n in range(N):
    distance = get_distance(X[n], Y[n])
    if distance <= D:
        ans += 1

# 結果出力
print(ans)


# Optimized solution
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N, D = list(map(int, input().split()))
    X, Y = [], []
    for n in range(N):
        X_n, Y_n = list(map(int, input().split()))
        X.append(X_n)
        Y.append(Y_n)

    return N, D, X, Y


def main(N: int, D: int, X: list, Y: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 点の個数
        D (int): 距離
        X (list): x座標
        Y (list): y座標
    """
    # 求解処理
    ans = 0
    for n in range(N):
        X_n = X[n]
        Y_n = Y[n]
        if X_n * X_n + Y_n * Y_n <= D * D:
            ans += 1

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, D, X, Y = get_input()

    # メイン処理
    main(N, D, X, Y)
# Original solution
import math
a,b = list(map(int,input().split()))
s = 0
l = [ list(map(int,input().split(" "))) for i in range(a)]
for i in range(a):
  if math.sqrt(l[i][0]**2+l[i][1]**2)<=b:
    s = s+1
print(s)
  

# Optimized solution
e=0
a,b=list(map(int,input().split()))
l = [ list(map(int,input().split(" "))) for i in range(a)]
for i in range(a):
  if l[i][0]**2+l[i][1]**2<=b**2:
    e=e+1
print(e)
# Original solution
n, d = list(map(int, input().split()))
x, y = list(zip(*[list(map(int, input().split())) for i in range(n)]))

ans = 0
for i in range(n):
    if (x[i]**2 + y[i]**2)**0.5 <= d:
        ans += 1

print(ans)

# Optimized solution
n, d = list(map(int, input().split()))
x, y = list(zip(*[list(map(int, input().split())) for i in range(n)]))
 
ans = 0
for i in range(n):
    if x[i]**2 + y[i]**2 <= d**2:
        ans += 1
 
print(ans)
# Original solution
def main():
    n,d = list(map(int, input().split()))
    res = 0
    for _ in range(n):
        x, y = list(map(int, input().split()))
        if (x**2+y**2)**.5 <= d:
            res += 1
    print(res)
main()

# Optimized solution
import sys
input = sys.stdin.readline

def main():
    n,d = list(map(int, input().split()))
    res = 0
    for _ in range(n):
        x, y = list(map(int, input().split()))
        if (x**2+y**2)**.5 <= d:
            res += 1
    print(res)
main()
# Original solution
def main():
    n, threshould = [int(x) for x in input().split()]
    count = 0
    for _ in range(n):
        x, y = [int(x) for x in input().split()]
        distance = (x ** 2 + y ** 2) ** 0.5
        if distance <= threshould:
            count += 1
    print(count)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n, threshould = [int(x) for x in input().split()]
    count = 0
    for _ in range(n):
        x, y = [int(x) for x in input().split()]
        if (x ** 2 + y ** 2) <= threshould ** 2:
            count += 1
    print(count)


if __name__ == '__main__':
    main()