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