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