n,m = map(int,input().split()) v = 0 for i in sorted(map(int,input().split())): m -= i if m >= 0: v += 1 print(v)