N = int(input())
S = input()

c_b = 0
c_w = 0

# # is black and . is white
c = 0

s_c = []
for i in range(N):
    if S[i] == '#':
        c_w += 1
        if c_b > 0:
            s_c.append(['.', c_b])
            c_b = 0
    else:
        c_b += 1
        if c_w > 0:
            s_c.append(['#', c_w])
            c_w = 0


if c_w > 0:
    s_c.append(['#', c_w])
    c_w = 0
if c_b > 0:
    s_c.append(['.', c_b])
    c_b = 0

c = 0
for i in range(len(s_c)-2, -1, -1):
    if s_c[i][0] == '#':
        if s_c[i+1][0] == '.':
            if s_c[i][1] > s_c[i+1][1]:
                c += min(s_c[i][1], s_c[i+1][1])

for i in range(1, len(s_c)):
    if s_c[i][0] == '.':
        if s_c[i-1][0] == '#':
            if s_c[i][1] > s_c[i-1][1]:
                c += s_c[i-1][1]
            else:
                c += s_c[i][1]

print(c)
