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