#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double PI = 3.14159265358979;
void Csum(vector<long long> &x) {
  for (int i = 0; i < x.size() - 1; i++) {
    x[i + 1] += x[i];
  }
  return;
}
int main() {
  long long N, x;
  cin >> N >> x;
  vector<long long> can(N);
  for (int i = 0; i < N; i++) {
    cin >> can[i];
  }
  sort(can.begin(), can.end());
  Csum(can);
  auto ans = lower_bound(can.begin(), can.end(), x + 1);
  cout << ans - can.begin();
}
