#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    long long int sum = 0;
    for (int i = 0; i < n; i++) cin >> v[i], sum += v[i];
    sort((v).begin(), v.end());
    float b = (float)sum / (float)n;
    if (b >= k) {
      cout << n << '\n';
      continue;
    }
    int i = 0;
    int f = 0;
    while (i < n) {
      sum -= v[i];
      float b = (float)sum / (float)(n - i - 1);
      if (b >= k) {
        f = 1;
        cout << n - i - 1 << '\n';
        break;
      }
      i++;
    }
    if (f == 0) cout << 0 << '\n';
  }
}
