#include <bits/stdc++.h>
using namespace std;
const int maxN = 100;
int n, x, a[maxN];
void run() {
  cin >> n >> x;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int tot = 0;
  for (int i = 0; i < n; ++i) {
    tot += a[i];
    if (tot > x) {
      cout << i << "\n";
      return;
    }
  }
  cout << n << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  run();
  return 0;
}
