my-solutions/codeforces/round-923/task-a/main.cpp

30 lines
525 B
C++
Raw Permalink Normal View History

#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
size_t n;
cin >> n;
std::string buffer;
cin >> buffer;
int first_b = -1;
int last_b = -1;
for (int j = 0; j < n; j++) {
if (buffer[j] == 'B') {
if (first_b == -1) {
first_b = j;
}
last_b = j;
}
}
cout << last_b - first_b + 1 << endl;
}
}