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