#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int INF = 1e9;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for (auto p : a) {
    if (p <= x) {
      ++ans;
      x -= p;
    } else {
      break;
    }
  }
  if (x > 0)
    cout << max(0, ans - 1) << endl;
  else
    cout << ans << endl;
  return 0;
}
