n, m = map(int, input().split()) C = list(map(int, input().split())) C.sort() c, cnt = 0, 0 for i in range(n): cnt += C[i] if cnt > m: break c += 1 print(c)