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