n, m = map(int, input().split()) c = list(map(int, input().split())) c.sort() i = 0 cnt = 0 while i < n and m - c[i] >= 0: cnt += 1 m -= c[i] i += 1 print(cnt)