#include <bits/stdc++.h>
using namespace std;
int arr[100];
int main() {
  int n, x, s = 0;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int j = 0;
  while (x > 0 && j < n) {
    if (x >= arr[j]) {
      x = x - arr[j];
      s += 1;
    }
    j++;
  }
  bool t = false;
  if (s != 0) t = true;
  if (x > 0 && t == true) s--;
  cout << s;
  return 0;
}
