#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void) {
  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 k = 0;
  int sum = 0;
  int ans = 0;
  for (int i = (0); i < (N); ++i) {
    sum += a[i];
    if (sum <= x) k++;
  }
  if (sum == x)
    ans = N;
  else if (sum <= x and k == N)
    ans = N - 1;
  else
    ans = k;
  cout << ans << endl;
  return 0;
}
