#include <bits/stdc++.h>
int main() {
  int N, x, res = 0, w = 0;
  scanf("%d%d", &N, &x);
  int a[N];
  for (int i = 0; i < N; i++) scanf("%d", &a[i]);
  std::sort(a, a + N);
  while (x > 0 && w < N) {
    x -= a[w++];
    res++;
  }
  if (x > 0 && w == N) res--;
  printf("%d", res);
  return 0;
}
