import heapq
def solution(n, k, enemy):
heap = []
result = 0
cnt = 0
for e in enemy:
heapq.heappush(heap, -e)
cnt += e
if cnt > n:
if not k:
return result
cnt += heapq.heappop(heap)
k-=1
result += 1
return result