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