#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
int main() {
  int n, x, ans = 0;
  vector<int> a;
  cin >> n >> x;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
  }
  if (x != 0 && ans > 0) ans--;
  cout << ans << endl;
}
