#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using df = vector<vll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
int main() {
  int n, x;
  cin >> n >> x;
  vll arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];
  sort(arr.begin(), arr.end());
  int sum = 0;
  for (int i = 0; i < n; ++i) sum += arr[i];
  int res = 0;
  if (sum == x) {
    res = n;
  } else if (sum < x) {
    res = n - 1;
  } else {
    sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += arr[i];
      if (sum > x) {
        res = i;
        break;
      }
    }
  }
  cout << res << endl;
}
