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