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