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