#include <bits/stdc++.h>
using namespace std;
long long a[105];
int main(void) {
  long long n, x;
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int cnt = 0, ans = 0, c = 0;
  for (int i = 1; i < n; i++) a[i] += a[i - 1];
  for (int i = 0; i < n; i++) {
    if (a[i] <= x) {
      ans++;
    }
  }
  if (a[ans - 1] != x) ans--;
  cout << max(ans, 0) << endl;
  return 0;
}
