#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin.tie(NULL);
  unsigned long long t = 0;
  cin >> t;
  while (t--) {
    unsigned long long n = 0;
    cin >> n;
    long long x = 0;
    cin >> x;
    vector<unsigned long long> a(n);
    long long sum = 0;
    for (unsigned long long i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    long long ans = sum / n;
    unsigned long long k = 0;
    unsigned long long n1 = n;
    sort(a.begin(), a.end());
    while (ans < x && k < n1) {
      n--;
      if (n == 0) n = 1;
      sum = sum - a[k];
      k++;
      ans = sum / n;
    }
    cout << n1 - k << '\n';
  }
}
