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