//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int H, W;
string smap[110];
int DP[110][110];
int hmap[110][110], vmap[110][110];

void func(int x, int y)
{
	int c = min(DP[y + 1][x], DP[y][x + 1]);
	if (smap[y][x] == '.')
	{
		queue<pii> q;
		q.push(mp(x, y));
		DP[y + 1][x + 1] = c;
		const static int dx[] = { 1,0 };
		const static int dy[] = { 0,1 };
		while (!q.empty())
		{
			auto p = q.front();
			q.pop();
			rep(k, 0, 2)
			{
				int nx = p.first + dx[k];
				int ny = p.second + dy[k];
				if (0 <= nx && nx < W && 0 <= ny && ny < H&&smap[ny][nx] == '.')
				{
					chmin(DP[ny + 1][nx + 1], c);
					q.push(mp(nx, ny));
				}
			}
		}
	}
	else
	{
		c++;
		int r = INF;
		rep(i, y, H)
		{
			if (smap[i][x] != '#')break;
			chmin(r, hmap[i][x]);
			rep(j, x, r)
			{
				chmin(DP[i + 1][j + 1], c);
			}
		}
	}
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W;
	rep(i, 0, H)
	{
		cin >> smap[i];
	}

	rep(i, 0, H + 1)rep(j, 0, W + 1)DP[i][j] = INF;

	rep(i, 0, H)
	{
		int l = -1;
		rep(j, 0, W)
		{
			if (smap[i][j] == '.')l = j;
			hmap[i][j] = l;
		}
	}

	rep(j, 0, W)
	{
		int u = -1;
		rep(i, 0, H)
		{
			if (smap[i][j] == '.')u = i;
			vmap[i][j] = u;
		}
	}

	DP[0][0] = DP[1][0] = DP[0][1] = 0;
	rep(i, 0, H)rep(j, 0, W)
	{
		if (smap[i][j] == '.')
		{
			DP[i + 1][j + 1] = min(DP[i + 1][j], DP[i][j + 1]);
		}
		else
		{
			int c = INF;
			if (i == 0 || smap[i - 1][j] == '.')chmin(c, DP[i][j + 1] + 1);
			else chmin(c, DP[i][j + 1]);
			if (j == 0 || smap[i][j - 1] == '.')chmin(c, DP[i + 1][j] + 1);
			else chmin(c, DP[i + 1][j]);
			DP[i + 1][j + 1] = c;
			/*int c = INF;
			int l = -1;
			rrep(y, 0, i + 1)
			{
				if (smap[y][j] == '.')break;
				chmax(l, hmap[y][j]);
				chmin(c, DP[y + 1][l + 1]);
			}
			int u = -1;
			rrep(x, 0, j + 1)
			{
				if (smap[i][x] == '.')break;
				chmax(u, vmap[i][x]);
				chmin(c, DP[u + 1][x + 1]);
			}
			DP[i + 1][j + 1] = c + 1;*/
		}
	}

	cout << DP[H][W] << endl;

	return 0;
}

Measured memory_bytes: 640