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