n,m = (int(x) for x in input().split()) l = list(map(int, input().split())) l.sort() c = 0 for x in l: m -= x if m<0: break else: c += 1 print(c)