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