n, idx = map(int, input().split())

apples = sorted((list(map(int, input().split())) + [i] for i in range(n)), key=lambda x: -x[2])

i = 0
while i < n and apples[i][4] != idx:
    i += 1
falling = [i]
i += 1
while i < n:
    cx, cy, cz, cr, k = apples[i]    
    for idx in falling:
        x, y, z, r, j = apples[idx]        
        if (cx - x)**2 + (cy - y)**2 < (cr + r)**2:
            falling.append(i)            
            break
    i += 1

print(n - len(falling))
        
    

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: