
alias Point = Tuple!(int, "x", int, "y");

void main() {
  auto H = scan!int, W = scan!int;
  bool[][] table = H.iota.map!(_ => scan.map!(c => c == '.').array).array;
  bool at(Point p){ return table[p.y][p.x]; }

  int solve() {
    
    int min = int.max;
    void bfs(Point p, int count) {
      p.deb;
      [count].deb;

      if (p.x == W - 1 && p.y == H - 1) {
        min = min > count ? count : min;
        return;
      }

      if (p.x < W - 1) {
        auto right = Point(p.x + 1, p.y);
        bfs(right, count + (at(p) && !at(right)));
      }

      if (p.y < H - 1) {
        auto down = Point(p.x, p.y + 1);
        bfs(down, count + (at(p) && !at(down)));
      }
    }

    auto init = Point(0, 0);
    bfs(init, at(init) ? 0 : 1);
    return min;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }

// -----------------------------------------------
