n, k =map(int,input().split())
data = list(map(int,input().split()))
data = sorted(data)
cnt = 0
for var in data:
    if var < k:
        cnt += 1
        k = k-var
       
    else:
        continue
print(cnt)      