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