#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 1;
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 1;
  sort(a, a + n, greater<long long>());
  long long sum = a[0];
  if (sum < k) {
    cout << "0\n";
    return;
  }
  bool f = 1;
  for (long long i = 1; i < n; i++) {
    sum += a[i];
    ans++;
    if (sum / ans < k) {
      f = 0;
      break;
    }
  }
  if (f == 0) {
    ans -= 1;
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
