#include <bits/stdc++.h>
using namespace std;
long long a[100010], aa[100010];
int main() {
  int T, n;
  long long x;
  scanf("%d", &T);
  while (T--) {
    scanf("%d %lld", &n, &x);
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      sum += a[i];
    }
    if (x * n <= sum) {
      printf("%d\n", n);
      continue;
    }
    sort(a + 1, a + 1 + n);
    if (a[n] < x) {
      printf("0\n");
      continue;
    }
    aa[n + 1] = 0;
    for (int i = n; i >= 1; i--) {
      aa[i] = aa[i + 1] + a[i];
      if (aa[i] < x * (n - i + 1)) {
        printf("%d\n", n - i);
        break;
      }
    }
  }
  return 0;
}
