#include <bits/stdc++.h>
using namespace std;
map<double, double>::iterator it;
pair<double, double> v;
map<double, double> u;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  double temp;
  double sum = 0;
  int c;
  cin >> t;
  for (int p = 0; p < t; p++) {
    c = 0;
    sum = 0;
    u.clear();
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
      cin >> temp;
      if (temp >= x) {
        c++;
        sum += temp - x;
      } else
        u[x - temp]++;
    }
    for (it = u.begin(); it != u.end(); it++) {
      v = *it;
      if (sum >= v.first) {
        temp = v.first * v.second;
        if (sum >= temp) {
          c += v.second;
          sum -= temp;
        } else {
          temp -= sum;
          double temp1 = temp / v.first;
          temp1 = int(ceil(temp1));
          temp1 = v.second - temp1;
          c += temp1;
          sum -= temp1 * v.first;
        }
      } else
        break;
    }
    cout << c << endl;
  }
  return 0;
}
