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