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.

Difficulty: interview

Starter code:

Solutions:
t = int(input())
for tc in range(t):
 seq = input()
 dollar = 0
 stamp = 0
 for ct in seq:
  if stamp >= 6:
   stamp -= 6
   continue
  elif ct == 'M':
   dollar += 3
  elif ct == 'L':
   dollar += 4
  stamp += 1
 print(dollar)




t=int(input())
while t>0:
 t-=1
 s=input()
 val=0
 ctr=0
 for i in s:
  if ctr==6:
   ctr=0
  else:
   if i=='M':
    val+=3
    ctr+=1
   else:
    val+=4
    ctr+=1
 print(val)


t = eval(input())
while t>0 :
 p = input()
 count = 0
 cost = 0
 i=0
 while i<len(p):
  if count == 6:
   count = 0
   i = i +1
   continue
  if p[i] == 'M':
   cost = cost + 3
  else:
   cost = cost + 4
  count = count +1
  i = i+1
 print(cost)
 t = t-1

t=int(input())
for _ in range(t):
 a=input()
 c=0
 m=0
 for i in range(len(a)):
  if c==6:
   c=0
   continue
  if a[i]=='M':
   m+=3
   c+=1
   continue
  if a[i]=='L':
   m+=4
   c+=1
   continue
 print(m)

for _ in range(eval(input())):
 l=list(map(str,input().strip()))
 print(sum([3 if j=='M' else 4 for i,j in enumerate(l) if (i+1)%7!=0]))


def f(s):
 s=list(s)
 cost=count=0
 for i in s:
  if count==6:
   count=0
   continue
  else:
   count+=1
   if i=="M":
    cost+=3
   else:
    cost+=4
 return cost
t=int(input())
for i in range(t):
 s=input()
 print(f(s))