#include <bits/stdc++.h>
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1) {
  unsigned day;
  if (dow < dow1) dow += 7;
  day = dow - dow1;
  day += 7 * n - 6;
  return day;
}
signed gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
signed lcm(int x, int y) { return x / gcd(x, y) * y; }
unsigned DayToWeekNumber(unsigned day) { return (day - 1) / 7 + 1; }
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0) {
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  int count = 0;
  for (int i = 0; i < (int)(N); i++) {
    cin >> a[i];
    count += a[i];
  }
  if (count == x)
    cout << N << endl;
  else if (count < x) {
    int A = x - count;
    int ans = N - 1;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for (int i = 0; i < (int)(N); i++) {
      if (x + a[i] >= count) {
        cout << ans << endl;
        return 0;
      }
      count -= a[i];
      ans--;
    }
  } else {
    int A = count - x;
    int ans = N - 1;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for (int i = 0; i < (int)(N); i++) {
      if (x + a[i] <= count) {
        cout << ans - 1 << endl;
        return 0;
      }
      count += a[i];
      ans--;
    }
  }
}
