#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 666666;
int n, x, a[N], res;
int main() {
  read(n);
  read(x);
  for (register int i = 1; i <= n; i++) read(a[i]);
  sort(a + 1, a + n + 1);
  for (register int i = 1; i <= n; i++)
    if (x >= a[i]) x -= a[i], res++;
  cout << res;
  return 0;
}
