P18450 [CodeChef] NYUMTEA
普及
题目描述

Bohan loves milk tea so much and he drinks one cup of milk tea every day. The local shop sells milk tea in two sizes: a Medium cup for $3 and a Large cup for $4. For every cup of milk tea purchased Bohan receives a promotional stamp. Bohan may redeem 6 stamps for a free drink of milk tea regardless of the size. No stamp will be given for a free drink.

Determine the amount of money Bohan have spent on milk tea, given a sequence of milk tea sizes he got in the past a few days. Assume Bohan had no stamps in the beginning and he always redeemed the stamps for the next drink once he had collected 6 stamps.

-----Input-----
The input begins with the number of test cases T.
Each test case has a single line of letters. The i-th letter is either 'M' or 'L' denoting a Medium cup or a Large cup of milk tea Bohan got on the i-th day.

-----Output-----
For each case, output the amount of money in dollars Bohan have spent on milk tea.

-----Constraints-----
- T ≤ 100
- 1 ≤ length of each sequence ≤ 100

-----Example-----
Input:
3
MLM
MMLLMMLL
MMMMMMML

Output:
10
24
22

-----Explanation-----
Example 1: Bohan didn't redeem any stamps.
Example 2: Bohan redeemed 6 stamps for the Large cup of milk tea on the 7th day.
Example 3: Bohan redeemed 6 stamps for the Medium cup of milk tea on the 7th day.

输入格式

见题面

输出格式

见题面

样例输入
['3', 'MLM', 'MMLLMMLL', 'MMMMMMML']
样例输出
['10', '24', '22']