#include <bits/stdc++.h>
int gcd(int a, int b) {
  int r = 1;
  while (r != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
void revStr(char *str) {
  int size = strlen(str);
  int i, j;
  char tmp = {0};
  for (i = 0, j = size - 1; i < size / 2; i++, j--) {
    tmp = str[i];
    str[i] = str[j];
    str[j] = tmp;
  }
  return;
}
struct data {
  int a, b, c;
};
int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int list[200000];
int tail;
void Init(void) { tail = 0; }
int Top(void) { return 0; }
int Next(int pos) {
  if (pos < tail - 1) {
    return pos + 1;
  } else {
    return -1;
  }
}
int Count(void) { return tail; }
int Item(int pos) {
  if ((pos >= 0) && (pos < tail)) {
    return list[pos];
  } else {
    return 0;
  }
}
void Add(int value) {
  if (tail < 200000) {
    list[tail] = value;
    tail++;
  }
}
void Delete(int pos) {
  if ((pos >= 0) && (pos < tail)) {
    int i;
    for (i = pos; i < tail - 1; i++) {
      list[i] = list[i + 1];
    }
    tail--;
  }
}
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  int chil[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &chil[i]);
  }
  int i = 0;
  qsort(chil, N, sizeof(int), compare_int);
  while (K > 0) {
    K -= chil[i];
    i++;
    if (i == N && K > 0) {
      printf("%d", i - 1);
      return 0;
    } else if (i == N && K == 0) {
      printf("%d", i);
      return 0;
    }
  }
  printf("%d", i);
}
