#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4 * atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
const int MAX_N = 105;
int N, x;
int a[MAX_N];
void solve() {
  int ans = 0;
  sort(a, a + N);
  for (int i = 0; i < N; ++i) {
    if (a[i] <= x) {
      x -= a[i];
      a[i] = 0;
    } else {
      a[i] -= x;
      break;
    }
  }
  for (int i = 0; i < N; ++i)
    if (a[i] == 0) ans++;
  if (x && ans) ans--;
  cout << ans << endl;
}
int main() {
  cin >> N >> x;
  for (int i = 0; i < N; ++i) cin >> a[i];
  solve();
}
