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