N, M = map(int,input().split()) cnt = 0 for c in sorted(map(int,input().split())): M -= c cnt += M >= 0 print(cnt)