n, m = list(map(int, input().split())) c = sorted(map(int, input().split())) x, y = 0, 0 for i in c: x += i if x > m: print(y) break y += 1 else: print(n)