#include <bits/stdc++.h>
using namespace std;
template <typename T>
void cinpb(vector<T>& x) {
  T n;
  cin >> n;
  x.push_back(n);
}
unsigned long long int gcd(unsigned long long int a, unsigned long long int b) {
  return b ? gcd(b, a % b) : a;
}
unsigned long long int lcm(unsigned long long int m, unsigned long long int n) {
  return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n);
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  int n, x;
  vector<int> a;
  cin >> n >> x;
  for (int i = 0; i < (int)(n); i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  int count = 0;
  for (size_t i = 0; i < a.size(); i++) {
    if (a[i] <= x) {
      count++;
    } else {
      break;
    }
    x -= a[i];
  }
  if (x != 0 && count > 0) count--;
  cout << count << endl;
  return 0;
}
