U504865 String

题目描述

hky accidentally received a piece of draft paper with scattered characters on it. He noticed that each character on the paper is one of ```USTB```. As a lover of ```USTB``` , he decided to fill the paper with ```USTB```. Given a string $S$ containing the characters ```USTB?``` where ```?``` represents a blank space that can be filled with any character, hky wants to maximize the number of times ```USTB``` appears in the final string. However, he doesn't care about the final string itself, so he just needs you to tell him the maximum number of times ```USTB``` can appear.

输入格式

There are multiple test cases. The first line of the input contains an integer $T$ indicating the number of test cases. For each test case: The only one line contains a string $S$. Ensure that the length of $S$ is less than or equal to $10^6$

输出格式

For each test case: Output an integer $ans$ on each line, representing the number of times the substring ```USTB``` appears in the final string.