#include<stdio.h>
int main(void)
{
char b;
int t,cou,sum;
scanf("%d",&t);
getchar();
while(t--)
{
cou=sum=0;
while((b=getchar())!='\n')
{
if(b=='O')sum+=++cou;
else cou=0;
}
printf("%d\n",sum);
}
return 0;
}
#include<stdio.h>
int main(void)
{
char b;
int t,cou,sum;
scanf("%d",&t);
getchar();
while(t--)
{
cou=sum=0;
while((b=getchar())!='\n')
{
if(b=='O')sum+=++cou;
else cou=0;
}
printf("%d\n",sum);
}
return 0;
}