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