#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    long long p, q, i, j, n, k, m, f, c = 0, t, s = 0;
    vector<long long int> v;
    vector<long long int> a;
    scanf("%lld%lld", &n, &m);
    for (i = 0; i < n; i++) {
      scanf("%lld", &k);
      v.push_back(k);
    }
    sort(v.begin(), v.end());
    for (i = n - 1; i >= 0; i--) {
      if (v[i] >= m) {
        c++;
        s = s + v[i] - m;
      } else {
        f = i;
        break;
      }
    }
    if (c == n) {
      cout << n << endl;
    } else if (c == 0) {
      cout << c << endl;
    } else {
      for (j = f; j >= 0; j--) {
        if ((v[j] + s) >= m) {
          c++;
          s = s - (m - v[j]);
        } else {
          break;
        }
      }
      cout << c << endl;
    }
  }
  return 0;
}
