_,S=eval(input()),eval(input())

numc,numw,numcmin=0,0,0

for s in S:

    if s == '#':

        numc = numc + 1

    else:

        numw = numw + 1

        numc = numc - 1

        if numc < numcmin:

            numcmin = numc

print((numcmin + numw))
_,S=eval(input()),eval(input())

numw=S.count('.')

numc,numcmin=0,0

for s in S:

    if s == '#':

        numc = numc + 1

    else:

        numc = numc - 1

        if numc < numcmin:

            numcmin = numc

print((numcmin+numw))
_, S = eval(input()), eval(input())
numc, numw, numcmin = 0, 0, 0
for s in S:
    if s == "#":
        numc = numc + 1
    else:
        numw = numw + 1
        numc = numc - 1
        if numc < numcmin:
            numcmin = numc
print((numcmin + numw))

_, S = eval(input()), eval(input())
numw = S.count(".")
numc, numcmin = 0, 0
for s in S:
    if s == "#":
        numc = numc + 1
    else:
        numc = numc - 1
        if numc < numcmin:
            numcmin = numc
print((numcmin + numw))

-numc, numw, numcmin = 0, 0, 0 +numw = S.count(".") +numc, numcmin = 0, 0 -        numw = numw + 1