#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    cin >> n >> x;
    long long int a[n];
    long long int i, k = INT_MAX, sum = 0, req;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n, greater<int>());
    for (i = 0; i < n; i++) {
      if (a[i] > x)
        sum += (a[i] - x);
      else {
        req = (x - a[i]);
        if (req > sum) {
          k = i;
          break;
        } else {
          sum -= req;
        }
      }
      if (k == INT_MAX) k = n;
    }
    cout << k << endl;
  }
  return 0;
}
