l = int(input()) n = int(input()) w = sorted((int(n) for n in input().split())) count = 0 ww = w[0] for i in range(l): if ww <= l: count += 1 ww += w[i+1] print(count)