from copy import copy

def rewrite(S,c):
    output = 0
    for i in range(1,len(S)):
        if S[i-1] == "B" and S[i] == "W":
            if c == "B":
                S[i-1] = "W"
            else:
                S[i] = "B"
            output += 1
    return output

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

b,w = 0,0
for i in range(N):
    if S[i] == ".":
        S[i] = "W"
        w += 1
    else:
        S[i] = "B"
        b += 1

S1,S2 = copy(S),copy(S)
print(min(rewrite(S1,"W"),rewrite(S2,"B")))
