#include <bits/stdc++.h>
int main() {
  int tc;
  long long int x, s[100000], sum = 0, count = 0, m, i;
  scanf("%d%lld", &tc, &x);
  for (i = 0; i < tc; i++) {
    scanf("%lld", &s[i]);
    sum += s[i];
  }
  if (sum < x) {
    m = x - sum;
    i = 0;
    while (i < tc) {
      if (m <= s[i]) count++;
      i++;
    }
  } else if (sum > x) {
    m = x;
    printf("%d\n", m);
    i = 0;
    while (i < tc) {
      if (m >= s[i]) count++;
      i++;
    }
  } else
    count = tc;
  printf("%lld\n", count);
}
