#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int M = 1e7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};
int main() {
  int n;
  ll x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int c = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (x >= a[i]) {
      c++;
      x -= a[i];
    } else {
      break;
    }
  }
  if (x != 0) c--;
  cout << max(c, 0) << endl;
  return 0;
}
