#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T> compress(vector<T> &C1, vector<T> &C2) {
  vector<T> vals;
  int N = (int)C1.size();
  for (int i = 0; i < N; i++) {
    for (T d = 0; d <= 1; d++) {
      T tc1 = C1[i] + d;
      T tc2 = C2[i] + d;
      vals.push_back(tc1);
      vals.push_back(tc2);
    }
  }
  sort(vals.begin(), vals.end());
  vals.erase(unique(vals.begin(), vals.end()), vals.end());
  for (int i = 0; i < N; i++) {
    C1[i] = lower_bound(vals.begin(), vals.end(), C1[i]) - vals.begin();
    C2[i] = lower_bound(vals.begin(), vals.end(), C2[i]) - vals.begin();
  }
  return vals;
}
using ll = long long;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  a.push_back(0);
  a.push_back(1e9);
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    a[i + 1] += a[i];
  }
  int ans = upper_bound(a.begin(), a.end(), x) - a.begin();
  if (lower_bound(a.begin(), a.end(), x) - a.begin() == N + 1) ans--;
  cout << ans - 1 << endl;
}
