#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool debug = false;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < int(n); i++) cin >> a[i];
  sort((a).begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x - a[i] >= 0) {
      ans++;
      x -= a[i];
    }
  }
  if (x != 0) ans--;
  cout << max(0, ans) << endl;
  return 0;
}
