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