#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;
int main() {
  int n, x;
  int a[110];
  cin >> n >> x;
  for (int i = (int)0; i < (int)n; ++i) cin >> a[i];
  sort(a, a + n);
  bool exist = false;
  int ans = 0, sum = 0;
  for (int i = (int)0; i < (int)n; ++i) {
    if (sum < x) {
      sum += a[i];
      if (sum > x) exist = true;
      if (exist) break;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
