#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long w = 1, s = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
int a[1000000];
int main() {
  int n = read(), m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    if (m < a[i]) {
      cout << i - 1;
      return 0;
    }
    m -= a[i];
  }
  return 0;
}
