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