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