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