#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, tc, kase;
  scanf("%d", &tc);
  while (tc--) {
    long long x, n;
    scanf("%lld %lld", &n, &x);
    vector<long long> v(n);
    long long sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%lld", &v[i]);
      sum += v[i];
    }
    sort(v.begin(), v.end());
    for (i = 0; i < n; i++)
      if (i != 0) v[i] += v[i - 1];
    long long cnt = 0;
    if (sum / x >= n) cnt = n;
    for (i = 1; i < n; i++) {
      if (((sum - v[i - 1]) / x) >= n - (i))
        cnt = max((min(sum - v[i - 1] / x, n - i)), cnt);
    }
    cout << cnt << endl;
  }
  return 0;
}
