#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
string converter(T n) {
  stringstream x;
  x << n;
  return x.str();
}
int dx[] = {1, 0};
int dy[] = {0, 1};
int main(void) {
  int n, x;
  cin >> n >> x;
  ;
  long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long sum = 0;
  long count = 0;
  for (int i = 0; i < n; i++) {
    if (sum + a[i] > x) break;
    sum += a[i];
    count++;
  }
  cout << count << '\n';
  return 0;
}
