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