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