N = int(input())
S = input()
sint = [0]
prev = S[0]
DEBUG = False
def dbg(*something):
    if DEBUG:
        print(*something)

for s in S:
    if prev == s:
        sint[-1] = sint[-1] + 1
    else:
        prev = s
        sint.append(1)
if len(sint) % 2 == 1:
    if S[0] == '#':
        sint = [0] + sint
    else:
        sint.append(0)
elif S[0] == '#':
    sint = [0] + sint + [0]
dbg(sint)

def count2(numSB,numSW):
    dbg('len:',len(sint))
    if len(sint) < 2:
        return 0
    sint.pop(0)
    sint.pop()
    
    if len(sint) < 2:
        return 0
    b = sint.pop(0)
    w = sint.pop()
    
    numSR =  b + w
    dbg(numSB,numSW,numSR)
    if numSB <= numSW and numSB <= numSR:
        return numSB
    elif numSW <= numSB and numSW <= numSR:
        return numSW
    else:
        return numSR + count2(numSB+b,numSW+w)
    # if numSB <= numSW :
    #     return numSB
    # else:
    #     return numSW
    
    

# def count(_S,_numSW,_numSB):
#     _S = _S.lstrip('.').rstrip('#')
#     if len(_S) == 0 :
#         return 0
#     numSW = _S.count('.')
#     numSB = _S.count('#')
#     SR = _S.lstrip('#').rstrip('.')
#     numSR = len(_S) - len(SR)
#     if numSW <= numSB and numSW <= numSR:
#         return numSW
#     elif numSB <= numSW and numSB <= numSR:
#         return numSB
#     else:
#         return numSR + count(SR)


numSB = 0
numSW = 0
for i,v in enumerate(sint):
    if i % 2 == 1:
        numSB = numSB + v
    else:
        numSW = numSW + v
#print(sint)
#print(sint,numSB,numSW,count2(numSB,numSW))
numSR = count2(numSB,numSW)
dbg('numSW:',numSW)
dbg('numSB',numSB)
dbg('numSR',numSR)
print(min(numSB,numSW,numSR))
'''
22
#####.....####..###...####....#.#.#
'''
# #intS = []
# def xor(A,B):
#     #print(A)
#     #print(B)
#     num = 0
#     for i in range(len(A)):
        
#         if A[i]!=B[i] :
#             num = num + 1
#     return num
# # for s in S :
# #     intS.append(0 if s=='.' else 1)
# minC = N

# mask = ['#' for j in range(len(S) + 1)]
# for i in range(len(S) + 1):
#     mask[i] = '.'
#     c = xor(mask[1::],S)
#     if c < minC:
#         minC = c

# print(minC)
# # def dl(_S):


# #     l = '.'
# #     r = '#'
    
# #     _S = _S.lstrip(l).rstrip(r)
# #     print(_S)
# #     if len(_S) == 0:
# #         return 0
# #     _S2W = _S.lstrip(r)
# #     _S2B = _S.rstrip(l)
# #     _S2 =  _S2W if len(_S2W) <= len(_S2B) else _S2B
# #     return len(_S) - len(_S2) + dl(_S2)
# # print(dl(S))




