include
using namespace std;
int main(){
int n;
char c[100];
cin>>n;
while(n>0){
cin>>c;
int len=strlen(c);
int count=0,score=0;
for(int i=0;i<len;i++){
if(c[i]=='O'||c[i]=='o') {
count++;
score=score+count;
}
else count=0;
}
cout<<score<<endl;
n--;
}
return 0;
}