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