def main():

  import sys

  buf=sys.stdin.buffer

  h,w=list(map(int,buf.readline().split()))

  c,*s,_=buf.readline()

  a=b=x=y=c==35

  d=[(b,a)]

  for c in s:

    f=c==35

    b+=a^f

    a=f

    d+=(b,a),

  for c,*s in buf.read().split():

    f=c==35

    y+=x^f

    b=y

    a=x=f

    p=[(b,a)]

    for i,c in enumerate(s,1):

      f=c==35

      b+=a^f

      c,g=d[i]

      c+=f^g

      if b>c:b=c

      a=f

      p+=(b,a),

    d=p

  print((b+1>>1))

main()
def main():

  import sys

  buf=sys.stdin.buffer

  h,w=list(map(int,buf.readline().split()))

  s=buf.readline()

  a=b=x=y=s[0]==35

  d=[b]

  e=[a]

  for i in range(1,w):

    f=s[i]==35

    b+=a^f

    a=f

    d+=b,

    e+=a,

  for s in buf.read().split():

    f=s[0]==35

    y+=x^f

    b=y

    a=x=f

    p=[b]

    q=[a]

    for i in range(1,w):

      f=s[i]==35

      b+=a^f

      c=d[i]+(f^e[i])

      if b>c:b=c

      a=f

      p+=b,

      q+=a,

    d=p

    e=q

  print((b+1>>1))

main()
def main():
    import sys

    buf = sys.stdin.buffer
    h, w = list(map(int, buf.readline().split()))
    c, *s, _ = buf.readline()
    a = b = x = y = c == 35
    d = [(b, a)]
    for c in s:
        f = c == 35
        b += a ^ f
        a = f
        d += ((b, a),)
    for c, *s in buf.read().split():
        f = c == 35
        y += x ^ f
        b = y
        a = x = f
        p = [(b, a)]
        for i, c in enumerate(s, 1):
            f = c == 35
            b += a ^ f
            c, g = d[i]
            c += f ^ g
            if b > c:
                b = c
            a = f
            p += ((b, a),)
        d = p
    print((b + 1 >> 1))


main()

def main():
    import sys

    buf = sys.stdin.buffer
    h, w = list(map(int, buf.readline().split()))
    s = buf.readline()
    a = b = x = y = s[0] == 35
    d = [b]
    e = [a]
    for i in range(1, w):
        f = s[i] == 35
        b += a ^ f
        a = f
        d += (b,)
        e += (a,)
    for s in buf.read().split():
        f = s[0] == 35
        y += x ^ f
        b = y
        a = x = f
        p = [b]
        q = [a]
        for i in range(1, w):
            f = s[i] == 35
            b += a ^ f
            c = d[i] + (f ^ e[i])
            if b > c:
                b = c
            a = f
            p += (b,)
            q += (a,)
        d = p
        e = q
    print((b + 1 >> 1))


main()

-    c, *s, _ = buf.readline() -    a = b = x = y = c == 35 -    d = [(b, a)] -    for c in s: -        f = c == 35 +    s = buf.readline() +    a = b = x = y = s[0] == 35 +    d = [b] +    e = [a] +    for i in range(1, w): +        f = s[i] == 35 -        d += ((b, a),) -    for c, *s in buf.read().split(): -        f = c == 35 +        d += (b,) +        e += (a,) +    for s in buf.read().split(): +        f = s[0] == 35 -        p = [(b, a)] -        for i, c in enumerate(s, 1): -            f = c == 35 +        p = [b] +        q = [a] +        for i in range(1, w): +            f = s[i] == 35 -            c, g = d[i] -            c += f ^ g +            c = d[i] + (f ^ e[i]) -            p += ((b, a),) +            p += (b,) +            q += (a,) +        e = q