#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, x;
    cin >> n >> x;
    long long int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    long double rich_sum = 0;
    long long int poor_idx = -1;
    for (int i = 0; i < n; i++) {
      if (arr[i] < x) {
        poor_idx = i;
      } else
        rich_sum += arr[i];
    }
    int i;
    for (i = poor_idx; i >= 0; i--) {
      rich_sum += arr[i];
      if (rich_sum / (n - i) < x) break;
    }
    int poor_cnt = i + 1;
    cout << (n - poor_cnt) << endl;
  }
}
