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