//{{{ 
// BEGIN CUT HERE

// END CUT HERE
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;

#define PB push_back
#define MP make_pair

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,l,h) for(int i=(l);i<=(h);++i)
#define FORD(i,h,l) for(int i=(h);i>=(l);--i)
#define SORT(vec) sort(vec.begin(), vec.end())

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
//}}}

const int hashmodcnt=2;
const int mod=1000000007;;
const int maxn=300010;

//{{{ 
ULL powmod(ULL n, ULL k, ULL _mod=mod)
{
	ULL ret = 1;
	while (k)
	{
		if (k&1)
			ret=ret*n%_mod;
		n=n*n%_mod;
		k>>=1;
	}
	return ret;
}
ULL hashmi[hashmodcnt][maxn];
ULL hashseed[hashmodcnt];
ULL hashmod[hashmodcnt];
ULL validseed[20] = {10007,10009,10037,10039,10061,10067,10069,10079,10091,10093,10099,10103,10111,10133,10139,10141,10151,10159,10163,10169};
ULL validmod[20] = {1000000007,1000000009,1000000021,1000000033,1000000087,1000000093,1000000097,1000000103,1000000123,1000000181,1000000207,1000000223,1000000241,1000000271,1000000289,1000000297,1000000321,1000000349,1000000363,1000000403};

void InitTemplate()
{
    srand(time(0));
    for (int i=0;i<hashmodcnt;i++)
    {
        hashseed[i] = validseed[rand()%20];
        hashmod[i] = validmod[rand()%20];
        hashmi[i][0] = 1;
        for (int j=1;j<maxn;j++)
            hashmi[i][j] = hashmi[i][j-1]*hashseed[i]%hashmod[i];
    }
}

struct Hash
{
	Hash()
	{
		memset(val, 0, sizeof(val));
		len=0;
	}

    Hash(ULL v)
    {
        len = 1;
        for (int i=0;i<hashmodcnt;i++)
            val[i] = v%hashmod[i];
    }

    Hash(const vector<int>& vec)
    {
        Hash tmp;
        for (int i=0;i<vec.size();i++)
            tmp = tmp.append(vec[i]);
        *this = tmp;
    }

    Hash(const string& s)
    {
        Hash tmp;
        for (int i=0;i<s.size();i++)
            tmp = tmp.append(s[i]);
        *this = tmp;
    }

	void merge(const Hash& lc, const Hash& rc)
    {
        len = lc.len+rc.len;
        for (int i=0;i<hashmodcnt;i++)
        {
            if (rc.len==0)
                val[i] = lc.val[i];
            else
                val[i] = (lc.val[i]*hashmi[i][rc.len]+rc.val[i])%hashmod[i];
        }
    }

    Hash append(ULL v) const
    {
        Hash ret(*this);
        ret.len++;
        for (int i=0;i<hashmodcnt;i++)
            ret.val[i] = (ret.val[i]*hashseed[i]+v)%hashmod[i];
        return ret;
    }

    Hash update(ULL v) const
    {
        return append(v);
    }

    Hash upd(ULL v) const
    {
        return append(v);
    }

    Hash operator+(const Hash& obj) const
    {
        Hash ret;
        ret.merge(*this, obj);
        return ret;
    }

    Hash operator-(const Hash& obj) const
    {
        Hash ret(*this);
        ret.len -= obj.len;
        for (int i=0;i<hashmodcnt;i++)
            ret.val[i] = (ret.val[i]-obj.val[i]*hashmi[i][ret.len]%hashmod[i] + hashmod[i])%hashmod[i];
        return ret;
    }

    bool operator<(const Hash& obj) const
    {
        if (len!=obj.len) return len<obj.len;
        for (int i=0;i<hashmodcnt;i++)if(val[i]-obj.val[i])
            return val[i]<obj.val[i];
        return false;
    }

    bool operator==(const Hash& obj) const
    {
        if (len!=obj.len) return false;
        for (int i=0;i<hashmodcnt;i++)if(val[i]-obj.val[i])
            return false;
        return true;
    }

    int len;
	unsigned long long val[hashmodcnt];
};

struct StaticClass
{
    StaticClass()
    {
        InitTemplate();
    }
};

static StaticClass _nonsence;

//}}}

int dis[110][110];
int vis[110][110];
char str[110][110];

int bfs(int n, int m)
{
    memset(dis, -1, sizeof(dis));
    dis[0][0]=(str[0][0]=='.'?0:1);
    queue<pair<int, int> > q;
    q.push(MP(0,0));
    vis[0][0]=1;

    while (!q.empty())
    {
        int u=q.front().first;
        int v=q.front().second;
        q.pop();
        vis[u][v]=0;

        if (u+1<n)
        {
            int d = dis[u][v]+(str[u+1][v]==str[u][v]?0:1);
            if (dis[u+1][v]<0 || dis[u+1][v]>d)
            {
                dis[u+1][v]=d;
                if (!vis[u+1][v])
                {
                    q.push(MP(u+1,v));
                    vis[u+1][v]=1;
                }
            }
        }
        if (v+1<m)
        {
            int d = dis[u][v]+(str[u][v+1]==str[u][v]?0:1);
            if (dis[u][v+1]<0 || dis[u][v+1]>d)
            {
                dis[u][v+1]=d;
                if (!vis[u][v+1])
                {
                    q.push(MP(u,v+1));
                    vis[u][v+1]=1;
                }
            }
        }
    }
    return dis[n-1][m-1];
}

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;i++)
        scanf("%s", str[i]);
    printf("%d\n", (bfs(n,m)+1)/2);
}



Measured memory_bytes: 4992