N = int(input())
S = input()
C = [0] * (N + 1)

for i in range(N):
    if S[i] == '#':
        C[i + 1] = C[i]  + 1
    else:
        C[i + 1] = C[i]


# print(C)

j = N
count = 0
while j > 0:
    jj = j - 1
    while jj >= 0 and C[jj] == C[j]:
        jj -= 1
    
    if jj >= 0 and jj < j - 1:
        count += j - jj - 1

    # print(j, jj)
    j = jj

print(count)
