#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e6 + 100;
inline bool read(long long &num) {
  char in;
  bool IsN = false;
  in = getchar();
  if (in == EOF) return false;
  while (in != '-' && (in < '0' || in > '9')) in = getchar();
  if (in == '-') {
    IsN = true;
    num = 0;
  } else
    num = in - '0';
  while (in = getchar(), in >= '0' && in <= '9') {
    num *= 10, num += in - '0';
  }
  if (IsN) num = -num;
  return true;
}
set<long long> st;
vector<long long> v[maxx];
double eps = 1e-10;
double a[maxx], b[maxx];
double sum[maxx];
map<long long, long long> mp;
int cmp(int a, int b) { return a > b; }
int main() {
  long long i, j, l, n;
  long long m;
  long long t, k;
  cin >> t;
  while (t--) {
    cin >> n;
    double p;
    cin >> p;
    for (i = 1; i <= n; i++) {
      scanf("%lf", &a[i]);
    }
    sort(a + 1, a + 1 + n, cmp);
    long long geshu = 0;
    for (i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
    for (i = 1; i <= n; i++) {
      double pp = (double)(sum[i] / i);
      if (pp - p >= 0) geshu = i;
    }
    printf("%lld\n", geshu);
  }
  return 0;
}
