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