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