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