#include <bits/stdc++.h>
using namespace std;
long long ceila(long long x, long long y) {
  long long k = x / y;
  if (y * k != x) k++;
  return k;
}
int32_t main() {
  long long t;
  cin >> t;
  for (long long i = 1; i <= t; i++) {
    long long n;
    long long x;
    cin >> n >> x;
    long long a[n + 1];
    long long suma = 0;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
      suma += a[i];
    }
    long long sum[n + 1];
    sort(a + 1, a + n + 1);
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      sum[i] = suma;
      suma -= a[i];
      if (sum[i] >= (n - i + 1) * x) {
        ans = n - i + 1;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
