#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;
int main() {
  int n, x;
  cin >> n >> x;
  vi a(n);
  ll asum = 0;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    asum += a[i];
  }
  if (asum > x)
    cout << n - 1 << endl;
  else {
    int ans = 0;
    sort(a.begin(), a.end());
    int i = 0;
    ;
    while (x - a[i] >= 0 && i != n) {
      x -= a[i];
      i++;
    }
    cout << i << endl;
  }
}
