l = int(input()) n = int(input()) w = list(map(int, input().split())) w.sort() width = 0 for i in range(n): width += w[i] if width > w: break else: i += 1 print(i)