N,M = map(int,input().split()) candies = [int(x) for x in input().split()] candies.sort() for box in range(N): candy = candies[box] if M>=candy: candies[box]=0 M-=candy else: break empty=len([x for x in candies if not x]) print(empty)