#include <bits/stdc++.h>
int R = 1, C = 1, H[2000010], N[2000010];
int hyouka(int a, int b) {
  if (C < b) return 1;
  if (C < a || b == 0) return 0;
  return N[H[a]] < N[H[b]] ? 1 : 0;
}
void hin(int a) {
  int i = C++;
  for (N[H[0] = R] = a; hyouka(0, i / 2); i /= 2) H[i] = H[i / 2];
  H[i] = R++;
}
int hout() {
  int rt = H[1], i, j = 2, k = H[--C];
  for (i = 1; hyouka(i, C); i = j)
    H[i] = H[j = i * 2 + 1 - hyouka(i * 2, i * 2 + 1)];
  H[j / 2] = k;
  return rt;
}
int main() {
  int n, m, i, a;
  scanf("%d %d", &n, &m);
  while (n--) {
    scanf("%d", &a);
    hin(a);
  }
  for (i = 0; C - 1; i++) {
    a = N[hout()];
    if (m < a) break;
    m -= a;
  }
  if (i && m) i--;
  printf("%d\n", i);
  return 0;
}
