#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int n, x, i, j, temp, a[100];
  cin >> n >> x;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n - 1; i++) {
    j = i + 1;
    temp = a[j];
    while (temp < a[j - 1] && j > 0) {
      a[j] = a[j - 1];
      j--;
    }
    a[j] = temp;
  }
  i = 0;
  while (i < n && x > 0) {
    x = x - a[i];
    i++;
  }
  if (x == 0)
    cout << i;
  else
    cout << i - 1;
}
