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 + count2(numSB-b,numSW-w)
    dbg(numSB,numSW,numSR)
    # if numSB <= numSW and numSB <= numSR:
    #     return numSB
    # elif numSW <= numSB and numSW <= numSR:
    #     return numSW
    # else:
    #     return numSR
    return numSR

def count3(numSB,numSW):
    dbg('len:',len(sint))
    numSR = 0
    while len(sint) >= 4:
    # 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 + numSR

    # if numSB <= numSW and numSB <= numSR:
    #     return numSB
    # elif numSW <= numSB and numSW <= numSR:
    #     return numSW
    # else:
    #     return numSR
    return numSR

def hoge(numSW):
    fuga = [1 for i in range(N)]
    numc = numSW
    numcmin = numc
    for s in S:
        if s == '#':
            #b2w
            numc = numc + 1
        else:
            numc = numc -1
            if numc < numcmin:
                numcmin = numc
    return numcmin


numSB = 0
numSW = 0
for i,v in enumerate(sint):
    if i % 2 == 1:
        numSB = numSB + v
    else:
        numSW = numSW + v

numSR = count3(numSB,numSW)
dbg('numSW:',numSW)
dbg('numSB',numSB)
dbg('numSR',numSR)
print(hoge(numSW))
'''
22
#####.....####..###...####....#.#.#
...################################
'''
