#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
    if (sum > x) {
      ans = i;
      break;
    }
  }
  if (ans != N)
    cout << ans << endl;
  else
    cout << N - 1 << endl;
  return 0;
}
