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