#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
int N, X;
int A[111];
void MAIN() {
  scanf("%d%d", &N, &X);
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%d", A + i);
  sort(A, A + N);
  int ans = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    if (X >= A[i]) {
      ans++;
    }
    X -= A[i];
  }
  if (X > 0) ans--;
  printf("%d\n", ans);
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
