#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, sum = 0;
  cin >> N >> x;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + N);
  int ans = 0, s = 0;
  for (int i = 0; i < N; i++) {
    if (s + a[i] < x) {
      s += a[i];
      ans++;
    } else
      break;
  }
  if (x > sum) ans--;
  cout << ans << endl;
}
