#include <bits/stdc++.h>
const int MAXN = 100;
using namespace std;
inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}
inline int read() {
  int x = 0, w = 1;
  char c = ' ';
  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * w;
}
int n, x, a[MAXN + 5];
void init() {
  n = read();
  x = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
}
int ans, sum;
int main() {
  init();
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i) {
    sum += a[i];
    if (sum <= x) ++ans;
  }
  if (ans == n && sum < x) --ans;
  printf("%d\n", ans);
  return 0;
}
