#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template <class T>
using V = vector<T>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;
  V<int> a = V<int>(N + 1);
  for (auto i = 1; i != N + 1; i++) cin >> a[i];
  sort(a.begin() + 1, a.end());
  for (auto i = 2; i != N + 1; i++) a[i] += a[i - 1];
  if (x == a[N]) {
    cout << N << endl;
    return 0;
  }
  int k = N;
  for (auto i = 1; i != N + 1; i++) {
    if (x < a[i]) {
      k = i - 1;
      break;
    }
  }
  if (k == N) {
    cout << N - 1 << endl;
  } else {
    cout << k << endl;
  }
  return 0;
}
