#include <bits/stdc++.h>
int a[105];
inline long long in() {
  long long k = 0;
  char ch = getchar();
  while (ch < '-') ch = getchar();
  while (ch > '-') k = k * 10 + ch - '0', ch = getchar();
  return k;
}
int main() {
  int n = in(), x = in();
  for (int i = 1; i <= n; ++i) a[i] = in();
  std::sort(a + 1, a + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (x < a[i]) break;
    x -= a[i], ans++;
  }
  printf("%d\n", ans);
  return 0;
}
