#include <bits/stdc++.h>
void ft_swap(long *a, long *b) {
  long tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}
void ft_qsort(long *tab, long left, long right) {
  long L, R;
  long pivot;
  L = left, R = right;
  pivot = tab[(L + R) / 2];
  while (1) {
    while (tab[L] > pivot) L++;
    while (tab[R] < pivot) R--;
    if (L >= R) break;
    ft_swap(&tab[L], &tab[R]);
  }
  if (L - 1 > left) ft_qsort(tab, left, L - 1);
  if (R + 1 < right) ft_qsort(tab, R + 1, right);
}
int main(void) {
  int N;
  long x;
  long i;
  scanf("%d", &N);
  scanf("%ld", &x);
  long a[N + 1];
  i = 1;
  while (i <= N) scanf("%ld", &a[i++]);
  ft_qsort(a, 1, N);
  long count = 0;
  i = 1;
  while (i <= N) {
    if (i != N && x > a[i]) {
      x -= a[i];
      count++;
    } else if (x == a[i]) {
      x -= a[i];
      count++;
      break;
    }
    if (i == N) {
      if (x == a[i]) {
        x -= a[i];
        count++;
      } else {
        break;
      }
    }
    i++;
  }
  printf("%ld", count);
  return 0;
}
