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