#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a, ll b, ll c) { return max(a, max(b, c)); }
ll MIN(ll a, ll b, ll c) { return min(a, min(b, c)); }
const ll mod = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
template <class T>
inline bool chmax(T& a, T& b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
inline bool chmin(T& a, T& b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
int main() {
  ll n, x, sum = 0;
  cin >> n >> x;
  ll num[n];
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    sum += num[i];
  }
  sort(num, num + n);
  if (sum > x) {
    sum = 0;
    ll counter = 0;
    bool check = true;
    if (x < num[0]) {
      check = false;
      cout << 0 << endl;
    }
    while (check) {
      sum += num[counter];
      counter++;
      if (sum >= x) {
        cout << counter << endl;
        break;
      }
    }
  } else if (sum < x) {
    cout << n - 1 << endl;
  } else {
    cout << n << endl;
  }
}
