#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  int max = 0;
  for (int i = 0; i < (n); ++i) {
    cin >> v[i];
    max += v[i];
  }
  sort(v.begin(), v.end());
  int ans = 0;
  int sum = 0;
  for (int i = 0; i < (n); ++i) {
    if ((sum + v[i]) > x) break;
    ans = i + 1;
    sum += v[i];
  }
  if (sum != x) {
    ans -= 1;
    if (ans == -1) ans = 0;
  }
  cout << ans << endl;
  return 0;
}
