#include <bits/stdc++.h>
void quick(int array[], int left, int right) {
  int pl = left, pr = right, x = array[(left + right) / 2];
  do {
    while (array[pl] < x) pl++;
    while (array[pr] > x) pr--;
    if (pl <= pr) {
      do {
        int t = array[pl];
        array[pl] = array[pr];
        array[pr] = t;
      } while (0);
      pl++, pr--;
    }
  } while (pl <= pr);
  if (pl < right) quick(array, pl, right);
  if (pr > left) quick(array, left, pr);
}
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  int a[102];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  quick(a, 0, n - 1);
  int count = 0;
  while (x - a[count] >= 0 && count < n) {
    x -= a[count++];
  }
  if (!(count == n - 1 && x == a[count])) count--;
  printf("%d\n", count);
  return 0;
}
