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