N, M = map(int, input().split()) for i, a in enumerate(sorted(map(int, input().split()))): M -= a if M < 0: print(i) break else: print(N)