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