#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int x;
  int *a;
  cin >> n >> x;
  a = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int sum = 0;
  int count = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum > x) {
      break;
    }
    count++;
  }
  cout << count;
  return 0;
}
