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