#include <bits/stdc++.h>
using ll = long long;
ll powmod(ll a, ll b, ll mod) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
using namespace std;
ll mod = 998244353;
const int N = 212345;
double a[N];
char s[N], temp[N];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < (n); i++) cin >> a[i];
    sort(a, a + n);
    ll ans = 0, sum = 0;
    for (int i = n - 1; i >= 0; i--) {
      sum += a[i];
      if (sum / (n - i) + 1e-9 > x) {
        ans++;
      } else {
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
