N = int(input())
S = input()
e = S.count('#.')
i = 0
cntB = 0
B = []
cntW = 0
W = []
for i in range(N):
    if S[i] == '#':
        if cntW != 0:
            W.append(cntW)
            cntW = 0
        cntB += 1
        if i == N - 1:
            B.append(cntB)
    else:
        if cntB != 0:
            B.append(cntB)
            cntB = 0
        cntW += 1
        if i == N - 1:
            W.append(cntW)

x = 0
for j in range(e):
    if W[-1] <= B[0]:
        x += W.pop(-1)
    else:
        x += B.pop(0)

print(x)