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