#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int inf = (int)1e9;
const long long INF = (long long)1e18;
const long long MOD{(long long)1e9 + 7};
const long double EPS = 1e-10;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (x - a[i] >= 0) {
      x -= a[i];
      cnt++;
    }
    if (i == n - 1 && x > 0) {
      cout << n - 1 << endl;
      return 0;
    }
  }
  cout << cnt << endl;
  return 0;
}
