#include <bits/stdc++.h>
using namespace std;
class XY {
 public:
  long long x, y;
  XY() { x = y = 0; }
  XY(long long u, long long v) {
    x = u;
    y = v;
  }
};
template <typename T1, typename T2>
void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
T1 mypow(T1 a, T2 n) {
  if (n == 0) return 1;
  if (n == 1) return a;
  if (n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}
template <typename T>
int BS(vector<T> V, int left, int right, T key) {
  int mid = (left + right) / 2;
  if (V[mid] <= key)
    left = mid;
  else
    right = mid;
  if (right - mid == 1)
    return left;
  else
    return BS(V, left, right, key);
}
bool isPrime(int n) {
  if (n == 1) return false;
  for (long long i = 2; i < min((int)(pow(n, 0.5) + 1), n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void Main() {
  long long N, x;
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i = 0; i < N; i++) cin >> a[i];
  sort((a).begin(), (a).end());
  long long res = 0;
  for (long long i = 0; i < N; i++) {
    if (N - a[i] >= 0) {
      N -= a[i];
      res++;
    } else {
      break;
    }
  }
  cout << res << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);
  Main();
}
