#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  for (int i = 0; i < ((int)vec.size()); i++) os << (i ? ", " : "") << vec[i];
  os << "]";
  return os;
}
template <typename T>
istream& operator>>(istream& is, pair<T, T>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T, T>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
int bitcnt(long long x) {
  x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
  x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
  x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
  x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
  x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
  x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
  return x;
}
int bitcnt(int x) {
  x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
  x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
  x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
  x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
  x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
  return x;
}
long long sqrtll(long long x) {
  long long left = 0, right = x;
  for (int i = 0; i < ((int)100); i++) {
    long long mid = (left + right) >> 1;
    if (mid * mid <= x)
      left = mid;
    else
      right = mid;
  }
  return left;
}
long long gcd(long long a, long long b) {
  return a % b == 0 ? b : gcd(b, a % b);
}
const long long inf = 1e9;
const long double infl = 1e100;
const long long mod = 998244353;
const long double eps = 1e-9;
const int dx[] = {1, 0, -1, 0, 0};
const int dy[] = {0, 1, 0, -1, 0};
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  cin >> a;
  sort((a).begin(), (a).end());
  int ret = 0;
  while (ret < n && x >= a[ret]) {
    x -= a[ret++];
  }
  if (x > 0) ret = max(0, ret - 1);
  cout << ret << endl;
  return 0;
}
