n, m = map(int, input().split()) c = list(map(int, input().split())) s = 0 ans = 0 for k in sorted(c): s += k if s <= m: ans += 1 print(ans)