#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  int nCand = 0;
  int n = 0;
  while (n < N) {
    nCand += a[n];
    if (nCand <= x) ans++;
    if (n == N - 1 && nCand < x) ans--;
    if (nCand == x) break;
    n++;
  }
  cout << ans << endl;
}
