# TPBC201C - Stones

import sys

input = sys.stdin.readline



n = int(eval(input()))

s = input().rstrip()

ans = 0

blk = 0

for i in s:

    if i == "#":

        blk += 1

    else:

        if blk > 0:

            ans += 1

            blk -= 1

print(ans)

# tenka1-2019-beginnerC - Stones

def main():

    N, S = open(0).read().split()

    ans, blk = 0, 0

    for i in S:

        if i == "#":

            blk += 1

        else:

            if blk:

                ans += 1

                blk -= 1

    print(ans)





if __name__ == "__main__":

    main()
# TPBC201C - Stones
import sys

input = sys.stdin.readline
n = int(eval(input()))
s = input().rstrip()
ans = 0
blk = 0
for i in s:
    if i == "#":
        blk += 1
    else:
        if blk > 0:
            ans += 1
            blk -= 1
print(ans)

# tenka1-2019-beginnerC - Stones
def main():
    N, S = open(0).read().split()
    ans, blk = 0, 0
    for i in S:
        if i == "#":
            blk += 1
        else:
            if blk:
                ans += 1
                blk -= 1
    print(ans)


if __name__ == "__main__":
    main()

-# TPBC201C - Stones -import sys +# tenka1-2019-beginnerC - Stones +def main(): +    N, S = open(0).read().split() +    ans, blk = 0, 0 +    for i in S: +        if i == "#": +            blk += 1 +        else: +            if blk: +                ans += 1 +                blk -= 1 +    print(ans) -input = sys.stdin.readline -n = int(eval(input())) -s = input().rstrip() -ans = 0 -blk = 0 -for i in s: -    if i == "#": -        blk += 1 -    else: -        if blk > 0: -            ans += 1 -            blk -= 1 -print(ans) + +if __name__ == "__main__": +    main()