importjava.io.*;publicclassMain{publicstaticvoidmain(String[] args)throwsIOException{BufferedReader bf =newBufferedReader(newInputStreamReader(System.in));BufferedWriter bw =newBufferedWriter(newOutputStreamWriter(System.out));intT=Integer.parseInt(bf.readLine());while(T-->0){String[] str = bf.readLine().split(" ");int n =Integer.parseInt(str[0]);int k =Integer.parseInt(str[1]);String s = bf.readLine();int ans =0, t =-1;for(int i =0; i < n; i++){if(s.charAt(i)=='B'&& i > t){
t = i + k -1;
ans++;}}
bw.write(ans +"\n");}
bw.close();}}
importjava.io.*;importjava.util.ArrayList;importjava.util.Collections;publicclassMain{publicstaticvoidmain(String[] args)throwsIOException{BufferedReader bf =newBufferedReader(newInputStreamReader(System.in));BufferedWriter bw =newBufferedWriter(newOutputStreamWriter(System.out));intT=Integer.parseInt(bf.readLine());while(T-->0){String[] str = bf.readLine().split(" ");int n =Integer.parseInt(str[0]);int x =Integer.parseInt(str[1]);
str = bf.readLine().split(" ");ArrayList<Integer> a =newArrayList<>();for(int i =0; i < n; i++){
a.add(Integer.parseInt(str[i]));}Collections.sort(a);long sum =0, ans =0;for(int i =0; i < n; i++){if(i !=0&& sum +(long) i *(a.get(i)- a.get(i -1))> x){
ans = a.get(i -1)+(x - sum)/ i;break;}if(i !=0){
sum +=(long) i *(a.get(i)- a.get(i -1));}if(i == n -1){
ans = a.get(i)+(x - sum)/ n;}}
bw.write(ans +"\n");}
bw.close();}}
importjava.io.*;publicclassMain{publicstaticvoidmain(String[] args)throwsIOException{BufferedReader bf =newBufferedReader(newInputStreamReader(System.in));BufferedWriter bw =newBufferedWriter(newOutputStreamWriter(System.out));intT=Integer.parseInt(bf.readLine());while(T-->0){String s = bf.readLine();int ans =0;int n = s.length();for(int i =0, j =-1; i <= n; i++){if(i == n || s.charAt(i)=='C'){int mn = n;for(int x =0, y = j; x <= i; x++){if(x < i && s.charAt(x)=='A') ans++;else{
mn =Math.min(mn, x - y -1);
y = x;}}
ans -= mn;}}
bw.write(ans +"\n");}
bw.close();}}