#include<bits/stdc++.h>

typedef long long ll;
using namespace std;

char maze[15][15];
struct node {
  int x, y;
};

bool cmp1(node a, node b) {
  return a.x != b.x ? a.x < b.x : a.y < b.y;
}

bool cmp2(node a, node b) {
  return a.y != b.y ? a.y < b.y : a.x < b.x;
}

void solve() {
  int n, m, ans = 0; scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", maze[i] + 1);
  }
  vector<node> vt;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (maze[i][j] == '#' and maze[i - 1][j] == '.') {
        vt.push_back(node{i, j});
      }
    }
  }
  double t1 = 0;
  for(int j = 0; j < 12; j++) t1++;
  double t2 = 0;
  t2--;
  for (int i = 0; i < 4; i++) t1 -= t2;
  sort(vt.begin(), vt.end(), cmp1);
  for (int i = 1; i < vt.size(); i++) {
    if (vt[i].x == vt[i - 1].x && vt[i].y == vt[i - 1].y + 1) {
      continue;
    }
    ans++;
  }
  t2++;
  t1++;
  ans += 1;
  vt.clear();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (maze[i][j] == '#' && maze[i + 1][j] == '.') {
        vt.push_back(node{i, j});
      }
    }
  }
  for (int i = 0; i < 4; i++) t1 -= t2;

  sort(vt.begin(), vt.end(), cmp1);
  for (int i = 1; i < vt.size(); i++) {
    if (vt[i].x == vt[i - 1].x && vt[i].y == vt[i - 1].y + 1) {
      continue;
    }
    ans++;
  }
  t2++;
  t1++;
  ans++;
  vt.clear();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (maze[i][j] == '#' && maze[i][j + 1] == '.') {
        vt.push_back(node{i, j});
      }
    }
  }
  for (int i = 0; i < 4; i++) t1 -= t2;

  sort(vt.begin(), vt.end(), cmp2);
  for (int i = 1; i < vt.size(); i++) {
    if (vt[i].y == vt[i - 1].y && vt[i].x == vt[i - 1].x + 1) {
      continue;
    }
    ans++;
  }
  for (int i = 0; i < 4; i++) t1 -= t2;

  t2++;
  t1++;
  ans += 1;
  vt.clear();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (maze[i][j] == '#' && maze[i][j - 1] == '.') {
        vt.push_back(node{i, j});
      }
    }
  }
  for (int i = 0; i < 4; i++) t1 -= t2;

  sort(vt.begin(), vt.end(), cmp2);
  for (int i = 1; i < vt.size(); i++) {
    if (vt[i].y == vt[i - 1].y && vt[i].x == vt[i - 1].x + 1) {
      continue;
    }
    ans++;
  }
  for (int i = 0; i < 4; i++) t1 -= t2;
  t2++;
  t1++;
  printf("%d\n", ++ans);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int T = 1; //cin >> T;
  while(T--) {
    solve();
  }
  return 0;
}  
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

///--->>> CONTAINERS <<<---///
using i64 = int64_t;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using vpi = vector<pair<ll,ll> >;
using pi = pair<ll,ll>;
using st = set<ll>;
using stk = stack<ll>;
using kiwi = queue<ll>;
using pkiwi = priority_queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;

///--->>> TEMPLATES <<<---///
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update >;

template<typename T>
T modpow(T a, T b){ll ans = 1; while(b>0) { if(b&1) ans*=a, b--; else a*=a, b>>=1;} return ans; }

///--->>> MACROS<<<---///
const ll mx = 3e6+123;
#define MOD 998244353
#define mod 1000000007
#define isb(z) __builtin_popcount(z)
#define lisb(z) __builtin_popcountll(z)
#define iclz(z) __builtin_clz(z)
#define lclz(z) __builtin_clzll(z)
#define ictz(z) __builtin_ctz(z)
#define lctz(z) __builtin_ctzll(z)
#define REP(i,n) for (ll i=1;i<=n;++i)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

///--->>>OPTIMIZE<<<---///
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

///--->>> DEBUGGER<<<---///
#define dbg(args...) do {cerr<<#args<<" : "; diraf(args); } while(0)
void diraf ()  {cerr << endl;}
template < typename T, typename ... hello>
void diraf( T arg, const hello &... rest) {cerr<<arg<< ' ';diraf(rest...);}

///--->>> RANDOMIZER<<<---///
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/* usage - just do rng() */

int main(int argc, char* argv[]){
    fastio;
	///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    ///cout<<fixed<<setprecision(20);
    cin.exceptions(cin.failbit);
   	ll height, width; cin>>height>>width;
   	char ch;
   	vector<vector<bool> > grid(height+1, vector<bool>(width+1, 0));
   	for(ll i = 0 ; i<height; ++i){
   		for(ll j = 0 ; j<width; ++j){
   			cin>>ch;
   			grid[i][j] = (ch=='#'? 1 : 0);
   		}
   	}
   	ll sides = 0;
   	for(ll i = 0 ; i<height - 1; ++i){
   		for(ll j = 0 ; j <width - 1; ++j){
   		    ll borders = 0;
   		    borders ^= grid[i+1][j];
   		    borders ^= grid[i][j+1];
   		    borders ^= grid[i+1][j+1];
   		    borders ^= grid[i][j];
   		    sides += borders;
   		}
   	}
   	cout<<sides<<endl;

return 0;
}
