N,M = map(int,input().split()) C = list(map(int,input().split())) C = sorted(C) answer = 0 counter = 0 for i in range(N) : if C[i] <= M - counter : answer += 1 counter += C[i] print(answer)