def main():

  _,*s=open(0)

  b,q='.'*101,list(range(101))

  for i,s in enumerate(s):

    a=[]

    for x,y,z,c in zip(b,'.'+s,s,q):

      c+=x=='.'>z

      i+=y=='.'>z

      if i>c:i=c

      a+=i,

    b,q=s,a

  print((a[-2]))

main()
def main():

  import sys

  input=sys.stdin.buffer.readline

  h,w=list(map(int,input().split()))

  b,q=b'.'*w,list(range(w))

  for i in range(h):

    s=eval(input())

    a=[]

    for x,y,z,c in zip(b,b'.'+s,s,q):

      c+=x==46>z

      i+=y==46>z

      if i>c:i=c

      a+=i,

    b,q=s,a

  print(i)

main()
def main():
    _, *s = open(0)
    b, q = "." * 101, list(range(101))
    for i, s in enumerate(s):
        a = []
        for x, y, z, c in zip(b, "." + s, s, q):
            c += x == "." > z
            i += y == "." > z
            if i > c:
                i = c
            a += (i,)
        b, q = s, a
    print((a[-2]))


main()

def main():
    import sys

    input = sys.stdin.buffer.readline
    h, w = list(map(int, input().split()))
    b, q = b"." * w, list(range(w))
    for i in range(h):
        s = eval(input())
        a = []
        for x, y, z, c in zip(b, b"." + s, s, q):
            c += x == 46 > z
            i += y == 46 > z
            if i > c:
                i = c
            a += (i,)
        b, q = s, a
    print(i)


main()

-    _, *s = open(0) -    b, q = "." * 101, list(range(101)) -    for i, s in enumerate(s): +    import sys + +    input = sys.stdin.buffer.readline +    h, w = list(map(int, input().split())) +    b, q = b"." * w, list(range(w)) +    for i in range(h): +        s = eval(input()) -        for x, y, z, c in zip(b, "." + s, s, q): -            c += x == "." > z -            i += y == "." > z +        for x, y, z, c in zip(b, b"." + s, s, q): +            c += x == 46 > z +            i += y == 46 > z -    print((a[-2])) +    print(i)