#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;
const int INF = 1e9;
const long long INFLL = 1e18;
using ll = long long;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> f(h);
  for(int i = 0; i < h; i++) cin >> f[i];

  int ans = 0;
  for(int i = 1; i < h; i++){
    for(int j = 1; j < w; j++){
      int cnt = 0;
      cnt += (f[i][j] == '#');
      cnt += (f[i-1][j] == '#');
      cnt += (f[i][j-1] == '#');
      cnt += (f[i-1][j-1] == '#');
      if(cnt % 2 == 1) ans ++;
    }
  }
  cout << ans << endl;

  return 0;
}
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, w; cin >> h >> w;
  vector<string> s(h); REP(i, h) cin >> s[i];
  auto f = [&](int y, int x, const vector<int> &check) {
    FOR(k, 4, 7) {
      int ny = y + dy8[k], nx = x + dx8[k];
      if (s[ny][nx] != (count(ALL(check), k) == 1 ? '#' : '.')) return false;
    }
    return true;
  };
  int ans = 0;
  FOR(i, 1, h) REP(j, w - 1) {
    if (s[i][j] == '#') {
      ans += f(i, j, {}) || f(i, j, {4, 5}) || f(i, j, {5, 6}) || f(i, j, {6, 4});
    } else {
      ans += f(i, j, {4}) || f(i, j, {5}) || f(i, j, {6}) || f(i, j, {4, 5, 6});
    }
  }
  cout << ans << '\n';
  return 0;
}
