#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const unsigned long long BS1 = 10000019ULL;
const int INF = (1 << 29);
template <class T>
inline void fastScan(T &x) {
  register char c = getchar();
  int neg = 0;
  x = 0;
  for (; (c < 48 || c > 57) && (c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
int n, choco;
int inp[N];
int main() {
  fastScan(n);
  fastScan(choco);
  for (int i = 1; i <= n; i++) {
    fastScan(inp[i]);
  }
  sort(inp + 1, inp + n + 1);
  int ans = 0, st = 1;
  while (st <= n && (choco - inp[st]) >= 0) {
    st++;
    choco -= inp[st - 1];
  }
  printf("%d\n", ans);
}
