#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long LINF = 1LL << 60;
const int INF = 1 << 30;
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }
  cout << ans << endl;
  return 0;
}
