#include <bits/stdc++.h>
using namespace std;
int main() {
  clock_t beg = clock();
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  int i = 0;
  while (i < n) {
    x -= a[i];
    if (x < 0) break;
    ans++;
    i++;
  }
  cout << ans;
  clock_t end = clock();
  fprintf(stderr, "%lf sec\n", (double)(end - beg) / CLOCKS_PER_SEC);
}
