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