n,m = map(int,input().split()) *c, = map(int,input().split()) c.sort() for i in range(n): if m >= c[i]: m -= c[i] else: print(i) break else: print(n)