#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (a.at(i) <= x) {
      ans++;
      if (a.at(i) == x) ans++;
      x -= a.at(i);
    } else
      break;
  }
  ans--;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}
