#include <bits/stdc++.h>
int n, s, x, a[1001];
int main() {
  scanf("%d%d", &n, &x);
  for (register int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    s += a[i];
  }
  if (x >= s) return printf("%d\n", n - (x > s)), 0;
  std::sort(a, a + n);
  int ans = 0;
  while (x >= 0) x -= a[ans++];
  return printf("%d\n", ans - 1), 0;
}
