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