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