#include <bits/stdc++.h>
int compare(const void *a, const void *b) {
  long long *A = (long long *)a;
  long long *B = (long long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
int main() {
  long long N, x, i, ans = 0;
  scanf("%lld%lld", &N, &x);
  long long a[N];
  for (i = 0; i < N; i++) scanf("%lld", &a[i]);
  qsort(a, N, sizeof(long long), compare);
  for (i = 0; x >= a[i]; i++) {
    x -= a[i];
    ans++;
  }
  if (x > 0 && ans > 0) ans--;
  printf("%lld\n", ans);
  return 0;
}
