#include <bits/stdc++.h>
int Cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int Max(int N, int x) {
  int i, S;
  int a[N];
  S = 0;
  for (i = 0; i < N; i++) scanf("%d", &a[i]);
  qsort(a, N, sizeof(int), Cmp);
  i = 0;
  while (1) {
    if (S + a[i] <= x) {
      S += a[i];
      i++;
    } else
      break;
  }
  if (S > x) i--;
  return i;
}
int main(void) {
  int N, x;
  scanf("%d %d", &N, &x);
  printf("%d\n", Max(N, x));
  return 0;
}
