N, M = map(int, input().split()) C = sorted(map(int, input().split())) cnt = 0 for i in range(N): S = sum(C[:i+1]) if M >= S: cnt += 1 print(cnt)