#include <bits/stdc++.h>
using namespace std;
const int INF = 1145141919, MOD = 1e9 + 7;
const long long LINF = 8101145141919364364, LMOD = 998244353;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    x -= a[i];
    if (x >= 0) cnt++;
  }
  if (x > 0) cnt--;
  cout << cnt << endl;
  return 0;
}
