N, K = map(int, input().split()) A = list(map(int, input().split())) A = sorted(A) ans = 0 for i in A: if K >= i: K -= i ans += 1 print(ans)