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