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