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