#include <bits/stdc++.h>
using namespace std;
int n, x, a[101];
inline int read() {
  register int save = 0, w = 1;
  register char q = getchar();
  while (q < '0' || q > '9') {
    if (q == '-') w = -1;
    q = getchar();
  }
  while (q >= '0' && q <= '9')
    save = (save << 3) + (save << 1) + q - '0', q = getchar();
  return save * w;
}
inline void Input() {
  n = read(), x = read();
  int i;
  for (i = 1; i <= n; ++i) a[i] = read();
  sort(a + 1, a + n + 1);
}
int main() {
  Input();
  int i, ans = 0;
  for (i = 1; i <= n; ++i) {
    if (x >= a[i])
      x -= a[i], ans++;
    else
      break;
  }
  printf("%d\n", ans);
  return 0;
}
