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