#include using namespace std; int main() { int T; scanf("%d", &T); assert(T >= 1 && T <= (int) 100); while (T--) { int n, K; scanf("%d %d", &n, &K); assert(n >= 1 && n <= 100); assert(K >= 1 && K <= n); vector votes(n); vector a; for (int i = 0; i < n; i++) { int x; scanf("%d", &x); assert(x >= 1 && x <= n); x--; a.push_back(x); votes[x]++; } int ans = 0; for (int i = 0; i < n; i++) { // person has voted to himself. He/she is disqualified. if (a[i] == i) continue; // if (votes[i] >= K) { ans++; } } printf("%d\n", ans); } return 0; }