n = int(eval(input()))



minv = res = rd = 0

for e in eval(input()):

    if e == ".":

        res += 1

        rd -= 1

        minv = min(minv, rd)

    else:

        rd += 1



print((res + minv))

eval(input())



minv = res = rd = 0

for e in eval(input()):

    if e == ".":

        res += 1

        rd -= 1

        if rd < minv:

            minv = rd

    else:

        rd += 1



print((res + minv))

n = int(eval(input()))
minv = res = rd = 0
for e in eval(input()):
    if e == ".":
        res += 1
        rd -= 1
        minv = min(minv, rd)
    else:
        rd += 1
print((res + minv))

eval(input())
minv = res = rd = 0
for e in eval(input()):
    if e == ".":
        res += 1
        rd -= 1
        if rd < minv:
            minv = rd
    else:
        rd += 1
print((res + minv))

-n = int(eval(input())) +eval(input()) -        minv = min(minv, rd) +        if rd < minv: +            minv = rd