from heapq import heapify, heappop, heappush N, M, *C = map(int, open(0).read().split()) heapify(C) for _ in range(M): if len(C) == 0: print(N) break t = heappop(C) t -= 1 if t != 0: heappush(C, t) else: print(N - len(C))