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