#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  register long long s = 0, t = 1;
  register char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') t = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * t;
}
inline void print(register int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 10000000;
int n;
long long x;
long long a[N + 1];
int main() {
  n = read();
  x = read();
  for (register int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + 1 + n);
  for (register int i = 1; i <= n + 1 && x >= 0; x -= a[i], i++)
    if (x < a[i] || i == n + 1) print(i - 1);
  return 0;
}
