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