#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double PI = acos(-1.0);
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 < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long cost = 0LL;
  long long res = 0LL;
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (cost + a[i] > x) break;
    cost += a[i];
    res++;
    if (i == n - 1) flag = false;
  }
  if (res > 0 && cost < x && flag) res--;
  cout << res << endl;
  return 0;
}
