#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
using namespace std;
template <class T1, class T2, class T3>
struct triple {
  T1 a;
  T2 b;
  T3 c;
  triple() : a(T1()), b(T2()), c(T3()){};
  triple(T1 _a, T2 _b, T3 _c) : a(_a), b(_b), c(_c) {}
};
template <class T1, class T2, class T3>
bool operator<(const triple<T1, T2, T3>& t1, const triple<T1, T2, T3>& t2) {
  if (t1.a != t2.a)
    return t1.a < t2.a;
  else if (t1.b != t2.b)
    return t1.b < t2.b;
  else
    return t1.c < t2.c;
}
template <class T1, class T2, class T3>
bool operator>(const triple<T1, T2, T3>& t1, const triple<T1, T2, T3>& t2) {
  if (t1.a != t2.a)
    return t1.a > t2.a;
  else if (t1.b != t2.b)
    return t1.b > t2.b;
  else
    return t1.c > t2.c;
}
inline int countBits(unsigned int v) {
  v = v - ((v >> 1) & 0x55555555);
  v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
  return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
inline int countBits(unsigned long long v) {
  unsigned int t = v >> 32;
  unsigned int p = (v & ((1ULL << 32) - 1));
  return countBits(t) + countBits(p);
}
inline int countBits(long long v) { return countBits((unsigned long long)v); }
inline int countBits(int v) { return countBits((unsigned int)v); }
unsigned int reverseBits(unsigned int x) {
  x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
  x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
  x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
  x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
  return ((x >> 16) | (x << 16));
}
template <class T>
inline int sign(T x) {
  return x > 0 ? 1 : x < 0 ? -1 : 0;
}
inline bool isPowerOfTwo(int x) { return (x != 0 && (x & (x - 1)) == 0); }
constexpr long long power(long long x, int p) {
  return p == 0 ? 1 : (x * power(x, p - 1));
}
template <class T>
inline bool inRange(const T& val, const T& min, const T& max) {
  return min <= val && val <= max;
}
unsigned long long rdtsc() {
  unsigned long long ret = 0;
  return __builtin_readcyclecounter();
  asm volatile("rdtsc" : "=A"(ret) : :);
  return ret;
}
const int __BS = 4096;
static char __bur[__BS + 16], *__er = __bur + __BS, *__ir = __er;
template <class T = int>
T readInt() {
  auto c = [&]() {
    if (__ir == __er)
      std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur;
  };
  c();
  while (*__ir && (*__ir < '0' || *__ir > '9') && *__ir != '-') ++__ir;
  c();
  bool m = false;
  if (*__ir == '-') ++__ir, c(), m = true;
  T r = 0;
  while (*__ir >= '0' && *__ir <= '9') r = r * 10 + *__ir - '0', ++__ir, c();
  ++__ir;
  return m ? -r : r;
}
string readString() {
  auto c = [&]() {
    if (__ir == __er)
      std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur;
  };
  string r;
  c();
  while (*__ir && isspace(*__ir)) ++__ir, c();
  while (!isspace(*__ir)) r.push_back(*__ir), ++__ir, c();
  ++__ir;
  return r;
}
char readChar() {
  auto c = [&]() {
    if (__ir == __er)
      std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur;
  };
  c();
  while (*__ir && isspace(*__ir)) ++__ir, c();
  return *__ir++;
}
static char __buw[__BS + 20], *__iw = __buw, *__ew = __buw + __BS;
template <class T>
void writeInt(T x, char endc = '\n') {
  if (x < 0) *__iw++ = '-', x = -x;
  if (x == 0) *__iw++ = '0';
  char* s = __iw;
  while (x) {
    T t = x / 10;
    char c = x - 10 * t + '0';
    *__iw++ = c;
    x = t;
  }
  char* f = __iw - 1;
  while (s < f) swap(*s, *f), ++s, --f;
  if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw;
  if (endc) {
    *__iw++ = endc;
  }
}
template <class T>
void writeStr(const T& str) {
  int i = 0;
  while (str[i]) {
    *__iw++ = str[i++];
    if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw;
  }
}
struct __FL__ {
  ~__FL__() {
    if (__iw != __buw) cout.write(__buw, __iw - __buw);
  }
};
static __FL__ __flushVar__;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p);
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const set<T1, T2>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const multiset<T1, T2>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, priority_queue<T1, T2> v);
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const map<T1, T2, T3>& v);
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const multimap<T1, T2, T3>& v);
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const triple<T1, T2, T3>& t);
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const set<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const multiset<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const map<T1, T2, T3>& v) {
  bool f = 1;
  os << "[";
  for (auto& ii : v) {
    if (!f) os << ", ";
    os << "(" << ii.first << " -> " << ii.second << ") ";
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const multimap<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& ii : v) {
    if (!f) os << ", ";
    os << "(" << ii.first << " -> " << ii.second << ") ";
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, priority_queue<T1, T2> v) {
  bool f = 1;
  os << "[";
  while (!v.empty()) {
    auto x = v.top();
    v.pop();
    if (!f) os << ", ";
    f = 0;
    os << x;
  }
  return os << "]";
}
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const triple<T1, T2, T3>& t) {
  return os << "(" << t.a << ", " << t.b << ", " << t.c << ")";
}
template <class T1, class T2>
void printarray(const T1& a, T2 sz, T2 beg = 0) {
  for (T2 i = beg; i < sz; i++) cout << a[i] << " ";
  cout << endl;
}
template <class T1, class T2, class T3>
inline istream& operator>>(istream& os, triple<T1, T2, T3>& t);
template <class T1, class T2>
inline istream& operator>>(istream& os, pair<T1, T2>& p) {
  return os >> p.first >> p.second;
}
template <class T>
inline istream& operator>>(istream& os, vector<T>& v) {
  if (v.size())
    for (T& t : v) os >> t;
  else {
    string s;
    T obj;
    while (s.empty()) {
      getline(os, s);
      if (!os) return os;
    }
    stringstream ss(s);
    while (ss >> obj) v.push_back(obj);
  }
  return os;
}
template <class T1, class T2, class T3>
inline istream& operator>>(istream& os, triple<T1, T2, T3>& t) {
  return os >> t.a >> t.b >> t.c;
}
template <class T1, class T2>
inline pair<T1, T2> operator+(const pair<T1, T2>& p1, const pair<T1, T2>& p2) {
  return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second);
}
template <class T1, class T2>
inline pair<T1, T2>& operator+=(pair<T1, T2>& p1, const pair<T1, T2>& p2) {
  p1.first += p2.first, p1.second += p2.second;
  return p1;
}
template <class T1, class T2>
inline pair<T1, T2> operator-(const pair<T1, T2>& p1, const pair<T1, T2>& p2) {
  return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second);
}
template <class T1, class T2>
inline pair<T1, T2>& operator-=(pair<T1, T2>& p1, const pair<T1, T2>& p2) {
  p1.first -= p2.first, p1.second -= p2.second;
  return p1;
}
const int USUAL_MOD = 1000000007;
template <class T>
inline void normmod(T& x, T m = USUAL_MOD) {
  x %= m;
  if (x < 0) x += m;
}
template <class T1, class T2>
inline T2 summodfast(T1 x, T1 y, T2 m = USUAL_MOD) {
  T2 res = x + y;
  if (res >= m) res -= m;
  return res;
}
template <class T1, class T2, class T3 = int>
inline void addmodfast(T1& x, T2 y, T3 m = USUAL_MOD) {
  x += y;
  if (x >= m) x -= m;
}
template <class T1, class T2, class T3 = int>
inline void submodfast(T1& x, T2 y, T3 m = USUAL_MOD) {
  x -= y;
  if (x < 0) x += m;
}
inline long long mulmod(long long x, long long n, long long m) {
  x %= m;
  n %= m;
  long long r =
      x * n - long long(long double(x) * long double(n) / long double(m)) * m;
  while (r < 0) r += m;
  while (r >= m) r -= m;
  return r;
}
inline long long powmod(long long x, long long n, long long m) {
  long long r = 1;
  normmod(x, m);
  while (n) {
    if (n & 1) r *= x;
    x *= x;
    r %= m;
    x %= m;
    n /= 2;
  }
  return r;
}
inline long long powmulmod(long long x, long long n, long long m) {
  long long res = 1;
  normmod(x, m);
  while (n) {
    if (n & 1) res = mulmod(res, x, m);
    x = mulmod(x, x, m);
    n /= 2;
  }
  return res;
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    T t = a % b;
    a = b;
    b = t;
  }
  return a;
}
template <class T>
T fast_gcd(T u, T v) {
  int shl = 0;
  while (u && v && u != v) {
    T eu = u & 1;
    u >>= eu ^ 1;
    T ev = v & 1;
    v >>= ev ^ 1;
    shl += (~(eu | ev) & 1);
    T d = u & v & 1 ? (u + v) >> 1 : 0;
    T dif = (u - v) >> (sizeof(T) * 8 - 1);
    u -= d & ~dif;
    v -= d & dif;
  }
  return std::max(u, v) << shl;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
template <class T>
inline T gcd(T a, T b, T c) {
  return gcd(gcd(a, b), c);
}
long long gcdex(long long a, long long b, long long& x, long long& y) {
  if (!a) {
    x = 0;
    y = 1;
    return b;
  }
  long long y1;
  long long d = gcdex(b % a, a, y, y1);
  x = y1 - (b / a) * y;
  return d;
}
template <class T>
bool isPrime(T x) {
  if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
  for (T i = 5; i * i <= x; i += 6)
    if (x % i == 0 || x % (i + 2) == 0) return 0;
  return 1;
}
bool millerRabin(long long n) {
  if (n <= 1000) return isPrime(n);
  long long s = n - 1;
  int t = 0;
  while (s % 2 == 0) s /= 2, ++t;
  for (int a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) {
    if (!(a %= n)) return true;
    long long f = powmulmod(a, s, n);
    if (f == 1 || f == n - 1) continue;
    for (int i = 1; i < t; ++i)
      if ((f = mulmod(f, f, n)) == n - 1) goto nextp;
    return false;
  nextp:;
  }
  return true;
}
int32_t solve();
int32_t main(int argc, char** argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  return solve();
}
int a[1010];
int solve() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    if (a[i] <= x) {
      x -= a[i];
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
