#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<time.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t --)
{
char a[100];
scanf("%s",a);
int ans = 0;
int tot = 0;
for(int i = 0; i < strlen(a); i ++)
{
if(a[i] == 'O')
{
tot++;
ans += tot;
}
else tot = 0;
}
printf("%d\n",ans);
}
return 0;
}#include<iostream>
#include<cstrin