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