N = int(input()) for i in range(N) : data = input() point,S = 0,0 for c in data : if c=='O' : point +=1 S += point else : point =0 print(S)