n,m = map(int,input().split()) a = list(map(int,input().split())) a = sorted(a) res = 0 for i in a: if i <= m: m -= i res += 1 print(res)