#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL << 60;
const long long MOD = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main(void) {
  int T;
  cin >> T;
  for (int _ = (0); _ < (T); ++_) {
    long long n, x;
    cin >> n >> x;
    vector<long long> a(n);
    for (int i = (0); i < (n); ++i) cin >> a[i];
    sort((a).begin(), (a).end());
    vector<long long> S(n + 1, 0);
    for (int i = (0); i < (n); ++i) S[i + 1] = S[i] + a[i];
    int ans = 0;
    for (int i = (n)-1; i >= (0); --i) {
      long long s = S[n] - S[n - i - 1];
      if ((long long)(i + 1) * x <= s) {
        ans = i + 1;
        break;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
