#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
int main() {
  int n, x, a[100], ans = 0, sum = 0;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (x > sum) {
    cout << n - 1 << endl;
    return 0;
  } else if (x == sum) {
    cout << n << endl;
    return 0;
  } else {
    sort(a, a + n);
    for (int i = n - 1; 0 <= i; i--) {
      if (x >= a[i]) {
        x -= a[i];
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
