"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var h = next(), w = next();
  var s = nexts(h,1);
  var map = xArray(0,h,w);
  var br = xArray(0,h,w);
  if(s[0][0] === "#")br[0][0] = 1, map[0][0] = 1;
  for(var i = 1; i < w; i++){
    if(s[0][i] === ".")map[0][i] = map[0][i-1];
    else{
      br[0][i] = 1;
      map[0][i] = map[0][i-1];
      if(br[0][i-1] === 0)map[0][i]++;
    }
  }
  for(var j = 1; j < h; j++){
    if(s[j][0] === ".")map[j][0] = map[j-1][0];
    else{
      br[j][0] = 1;
      map[j][0] = map[j-1][0];
      if(br[j-1][0] === 0)map[j][0]++;
    }
  }
  for(var i = 1; i < w; i++)for(var j = 1; j < h; j++){
    if(s[j][i] === ".")map[j][i] = Math.min(map[j][i-1],map[j-1][i]);
    else{
      br[j][i] = 1;
      map[j][i] = Math.min(map[j][i-1]-br[j][i-1]+1,map[j-1][i]-br[j-1][i]+1);
    }
  }
  return map[h-1][w-1];
}