#include <bits/stdc++.h>
using namespace std;
inline long long getint() {
  register long long num = 0;
  register char c;
  while (!isdigit(c = getchar()))
    ;
  while (isdigit(c)) num = (num << 1) + (num << 3) + (c ^ 48), c = getchar();
  return num;
}
inline void outint(long long a) {
  static char ch[23];
  if (a == 0) putchar('0');
  while (a) ch[++ch[0]] = (a - a / 10 * 10) ^ 48, a /= 10;
  while (ch[0]) putchar(ch[ch[0]--]);
}
long long a[101];
int n;
long long x;
signed main() {
  n = getint();
  x = getint();
  for (int register i = 1; i <= n; ++i) a[i] = getint();
  sort(a + 1, a + n + 1);
  int i = 1;
  for (; i <= n; ++i) {
    if (x < a[i]) break;
    x -= a[i];
  }
  if (i <= n)
    outint(i - 1);
  else if (x != 0)
    outint(n - 1);
  return 0;
}
