count = int(input())
data = input().strip()
score = 0
bonus = 0
in_a_raw = True
for i in range(0,count):
if data[i]=='O':
score += (i+1)
score += bonus
in_a_raw = True
bonus += 1
#print(score)
else:
bonus = 0
in_a_raw = False
print(score)
N, S = input(), input()
score, bonus = 0, 0
for idx, OX in enumerates(S):
if OX == 'O':
score += idx+1+bonus
bonus +=1
#위의 2줄을 한줄로 바꾸면 아래와 같다:
#score, bonus = score + idx+1+bonus, bonus+1
else:
bonus = 0
print(score)