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