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