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