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