n,m = map(int, raw_input().split()) l = sorted(map(int, raw_input().split())) i = 0 while m > 0: m -= l[i] i += 1 if m == 0: print i else: print i-1