#include<bits/stdc++.h>

using namespace std;

int main()

{

int t,n,a[n],k;

cin>>t;

for(int j =1;j<=t;j++)

{ int count=0;

cin>>n>>k;

int m=sizeof(a)/sizeof(a[0]);

for(int j=0;j<n;j++)

{

cin>>a[j];

```
}
sort(a, a+n, greater<int>());
for(int j=0;j<n;j++)
{
if(a[j]>=a[k-1])
count+=1;
}
cout<<count;
}
return 0;
```

}