#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
const long long MOD = 1e9 + 7;
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long k = 0;
  long long sum = 0;
  for (int i = 0; i < (int)(n); i++) {
    sum += a[i];
    if (sum > x) k = i + 1;
  }
  cout << k << endl;
}
