N, M = map(int, input().split()) C = sorted(list(map(int, input().split()))) ans = 0 for c in C: if c <= M: M -= c ans += 1 print(ans)