import sys

import numpy as np

sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

    S = eval(input())

    White = np.zeros(n + 1)

    Black = np.zeros(n + 1)



    for i in range(n):

        if S[i] == "#":

            Black[i + 1] = Black[i] + 1

        else:

            Black[i + 1] = Black[i]



    for i in reversed(list(range(n))):

        if S[i] == ".":

            White[i] = White[i + 1] + 1

        else:

            White[i] = White[i + 1]



    res = White + Black

    print((int(min(res))))





if __name__ == '__main__':

    resolve()

import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

    s = eval(input())



    b = [0] * n

    cnt = 0

    for i in range(n):

        if s[i] == "#":

            cnt += 1

        b[i] = cnt



    w = [0] * n

    cnt = 0

    for i in reversed(list(range(n))):

        if s[i] == ".":

            cnt += 1

        w[i] = cnt



    res = f_inf

    w = w + [0]

    b = [0] + b

    for i, j in zip(w, b):

        res = min(res, i + j)

    print(res)





if __name__ == '__main__':

    resolve()

import sys
import numpy as np

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    S = eval(input())
    White = np.zeros(n + 1)
    Black = np.zeros(n + 1)
    for i in range(n):
        if S[i] == "#":
            Black[i + 1] = Black[i] + 1
        else:
            Black[i + 1] = Black[i]
    for i in reversed(list(range(n))):
        if S[i] == ".":
            White[i] = White[i + 1] + 1
        else:
            White[i] = White[i + 1]
    res = White + Black
    print((int(min(res))))


if __name__ == "__main__":
    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    s = eval(input())
    b = [0] * n
    cnt = 0
    for i in range(n):
        if s[i] == "#":
            cnt += 1
        b[i] = cnt
    w = [0] * n
    cnt = 0
    for i in reversed(list(range(n))):
        if s[i] == ".":
            cnt += 1
        w[i] = cnt
    res = f_inf
    w = w + [0]
    b = [0] + b
    for i, j in zip(w, b):
        res = min(res, i + j)
    print(res)


if __name__ == "__main__":
    resolve()

-import numpy as np -    S = eval(input()) -    White = np.zeros(n + 1) -    Black = np.zeros(n + 1) +    s = eval(input()) +    b = [0] * n +    cnt = 0 -        if S[i] == "#": -            Black[i + 1] = Black[i] + 1 -        else: -            Black[i + 1] = Black[i] +        if s[i] == "#": +            cnt += 1 +        b[i] = cnt +    w = [0] * n +    cnt = 0 -        if S[i] == ".": -            White[i] = White[i + 1] + 1 -        else: -            White[i] = White[i + 1] -    res = White + Black -    print((int(min(res)))) +        if s[i] == ".": +            cnt += 1 +        w[i] = cnt +    res = f_inf +    w = w + [0] +    b = [0] + b +    for i, j in zip(w, b): +        res = min(res, i + j) +    print(res)