N, M = map(int, raw_input().split()) C = map(int, raw_input().split()) total = 0 count = 0 for c in sorted(C): total += c if total > M: break count += 1 print count