#include using namespace std; int n; long long m; long long a[500005]; long long check(long long now) { int tot = lower_bound(a + 1, a + n + 1, now) - a - 1; // printf("%d\n", tot); long long nowm = m; long long ans = 0; while(a[tot + 1] == now && tot + 1 <= n) tot++; while(nowm >= (now - a[tot]) && tot >= 1) { nowm -= now - a[tot], ans++, tot--; // printf("%lld %d\n", nowm, tot); } return ans; } int main() { freopen("crystal.in", "r", stdin); // freopen("crystal.out", "w", stdout); scanf("%d%lld", &n, &m); for(int i = 1; i <= n; ++i) scanf("%lld", &a[i]); sort(a + 1, a + n + 1); long long ans = 0; for(int i = 1; i <= n; ++i) { ans = max(ans, check(a[i])); } printf("%lld\n", ans); // printf("%lld\n", check(4)); return 0; } /* g++ crystal/crystal.cpp -o crystal/crystal -std=c++14 -O2 -static -Wall && cp crystal/crystal ~ && chmod +x ~/crystal && ~/crystal O(n log n) 45pts */