Baran has a strip of land in the beautiful city of Afrin, a city renowned for its delicious olive oil, lush green nature, and generous people. Visitors to Afrin are always captivated by its stunning scenery.
Baran's land is represented as a single line of $$$n$$$ cells. Each cell can be in one of four states:
Baran plans to walk along this line of cells exactly once, from the first cell to the last. He has a vehicle that can carry a total of $$$M$$$ kilograms of items. For simplicity, we assume one bag of water weighs 1 kg and one unit of harvested olives also weighs 1 kg.
During his single pass, Baran has two objectives:
The total weight of water bags and olive units in his vehicle cannot exceed $$$M$$$ at any point in time.
Can you help Baran determine the maximum number of olive units he can collect while ensuring all needy trees are watered?
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 10^5$$$). The description of the $$$T$$$ test cases follows.
The first line of each test case contains two integers $$$N$$$ and $$$M$$$ ($$$1 \le N \le 10^5$$$, $$$1 \le M \le 10^5$$$), representing the number of cells in the land and the vehicle's capacity, respectively.
The second line of each test case contains a string of length $$$N$$$, describing the land. Each character is one of ., O, T, or W.
It is guaranteed that the sum of $$$N$$$ over all test cases does not exceed $$$10^5$$$.
For each test case, print a single integer on a new line. This integer should be the maximum number of olive units Baran can collect. If it is impossible to water all the trees that need it, print -1.
48 2.OOWTWTO7 2TOOWTWT5 3.OOOO12 3OWWTWTTOOOOO
2 -1 3 3
First Test Case:
The number of 'O's inside the vehicle is 2, so the answer is: $$$2$$$
Second Test Case:
The answer is: $$$-1$$$
Third Test Case:
The answer is: $$$3$$$
Fourth Test Case: