#include <bits/stdc++.h>
using namespace std;
int main() {
  long long ans = 0, i = 0, j = 0, k = 0, l = 0;
  long long N, x, a[100] = {0};
  cin >> N >> x;
  for (i; i < N; i++) cin >> a[i];
  sort(a, a + N);
  for (i = 0; i < N; i++) {
    x -= a[i];
    if (x >= 0) {
      if (a[i + 1])
        ans++;
      else if (x == 0)
        ans++;
    } else
      break;
  }
  cout << ans << endl;
  return 0;
}
