#include <bits/stdc++.h>
using namespace std;
int n, x;
int a[200];
int main() {
  cin >> n >> x;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      sum++;
    }
  }
  if (x > 0) sum--;
  if (sum < 0) sum = 0;
  cout << sum << endl;
  return 0;
}
