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