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

flag_b = False
count_b = 0
count_w = 0
ans = 0
buf = S[0]
S += "e" # 終了判定のため末尾に挿入

for s in S:
    if s == buf:
        if s == "#":
            count_b += 1
        else:
            count_w += 1
    else:
        if s == "#":
            ans += min(count_b, count_w)
            count_b = 1
            count_w = 0
        elif s == ".":
            count_w = 1
        else:
            ans += min(count_b, count_w)
    buf = s

print(ans)