#K70912. Maximizing Pizzas

    ID: 33414 Type: Default 1000ms 256MiB

Maximizing Pizzas

Maximizing Pizzas

You are given a string S of length N consisting of characters 'P' (for pizza) and 'B' (for broccoli). You are allowed to change at most one subsequence of characters, where each character in the chosen subsequence is originally 'B', into 'P'. Note that a subsequence here is defined as any collection of indices (not necessarily contiguous). Thus, you can choose all occurrences of 'B' if you want.

After performing the conversion, compute the maximum number of pizzas (i.e. the total number of 'P's) you can obtain.

Observation: Since any subsequence of 'B's can be chosen (even non‐contiguous), you can always convert all 'B's to 'P's. Hence, the maximum number of pizzas is given by \[ \text{Maximum Pizzas} = N, \] where \(N\) is the length of the string.

inputFormat

The first line contains an integer T (1 ≤ T ≤ 100), the number of test cases.

Each test case consists of two lines. The first line contains an integer N (1 ≤ N ≤ 105), the length of the string S. The second line contains the string S which consists only of the characters 'P' and 'B'.

It is guaranteed that the total length of all strings does not exceed 106.

outputFormat

For each test case, output a single integer — the maximum number of pizzas that can be obtained after converting at most one subsequence of 'B's into 'P's.

Since converting all 'B's to 'P's is always allowed, the answer is simply N (the length of the string).

## sample
5
5
PPPPP
7
PPBBPPP
12
PBPBPBPBPBPP
1
B
4
BBPP
5

7 12 1 4

</p>