#include <bits/stdc++.h>
using namespace std;
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());
  if (x < a[0]) {
    cout << 0 << endl;
    return 0;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (x - a[i] < 0) break;
    cnt++;
    x -= a[i];
  }
  if (x != 0) cnt--;
  cout << cnt << endl;
  return 0;
}
