#include "bits/stdc++.h" using namespace std; const int N = 100; int t, n, k, x; int arr[N], votes[N]; int main(){ cin >> t; while(t--){ cin >> n >> k; fill(votes, votes + n, 0); for(int i = 0; i < n; i++){ cin >> x; arr[i] = x - 1; ++votes[arr[i]]; } int good_people = 0; for(int i = 0; i < n; i++){ if(votes[i] >= k and arr[i] != i) ++good_people; } cout << good_people << '\n'; } }