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