#include <bits/stdc++.h>
using namespace std;
int main() {
  long long ans = 0, temp = 0, i = 0, 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());
  for (int i = 0; i < n; i++) {
    if (temp > x) break;
    temp += a[i];
    ans++;
  }
  cout << (ans == n ? n - 1 : ans) << endl;
}
