for _ in range(int(input())) :
    score = res = 0
    for s in input() :
        if s == 'O' :
            score += 1
            res += score
        elif score != 0 :
            score = 0
    print(res)