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