#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.at(i);
  int sum = 0;
  for (int i = 0; i < N; i++) sum += a.at(i);
  if (sum == x)
    cout << N << endl;
  else if (sum <= x)
    cout << N - 1 << endl;
  else {
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; x >= a.at(i); i++) {
      x -= a.at(i);
      ans++;
    }
    if (x < a.at(0))
      cout << 0 << endl;
    else
      cout << ans << endl;
  }
}
