#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, m;
int level[300010], head[300010], vis[300010], vis2[300010];
char s[300][300];
int ecnt = 1, S = 210000, T = 220000;
int cnt = 0;
const long long inf = 1e13;
struct Node {
  int to, nxt;
  long long w;
} edge[2 * 300010];
void add(int from, int to, long long w) {
  edge[++ecnt].nxt = head[from];
  edge[ecnt].to = to;
  edge[ecnt].w = w;
  head[from] = ecnt;
}
void add2(int u, int v, long long w) {
  add(u, v, w);
  add(v, u, 0);
}
bool bfs(int s, int t) {
  memset(level, 0, sizeof(level));
  level[s] = 1;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; ~i; i = edge[i].nxt) {
      int d = edge[i].to;
      if (!level[d] && edge[i].w) {
        level[d] = level[u] + 1;
        q.push(d);
        if (d == t) return 1;
      }
    }
  }
  if (level[t]) return 1;
  return 0;
}
long long dfs(int now, int t, long long minf) {
  if (now == t || minf == 0) return minf;
  long long cw = 0, used = 0;
  for (int i = head[now]; ~i && minf; i = edge[i].nxt) {
    int go = edge[i].to;
    if (edge[i].w && level[go] == level[now] + 1) {
      cw = dfs(go, t, min(minf, (long long)edge[i].w));
      edge[i].w -= cw;
      edge[i ^ 1].w += cw;
      minf -= cw;
      used += cw;
    }
  }
  if (!used) level[now] = 0;
  return used;
}
long long Dinic(int s, int t) {
  long long ans = 0;
  while (bfs(s, t)) {
    long long tmp = dfs(s, t, inf);
    ans += tmp;
  }
  return ans;
}
int getid(int r, int c, char op) {
  if ((r == 1 && op == 'u') || (c == 1 && op == 'l') || (r == n && op == 'd') ||
      (c == m && op == 'r'))
    return 0;
  if (op == 'l')
    return 2 * ((r - 1) * m + c) + 1;
  else if (op == 'd')
    return 2 * ((r - 1) * m + c) + 2;
  else if (op == 'u')
    return getid(r - 1, c, 'd');
  else if (op == 'r')
    return getid(r, c + 1, 'l');
}
void buildgraph() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == '.') {
        cnt++;
        vis[getid(i, j, 'u')] = 1;
        vis[getid(i, j, 'd')] = 1;
        vis[getid(i, j, 'l')] = 1;
        vis[getid(i, j, 'r')] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int l = getid(i, j, 'l'), d = getid(i, j, 'd'), u = getid(i, j, 'u'),
          r = getid(i, j, 'r');
      if (!vis[l] && !vis2[l]) {
        add2(S, l, 1);
        vis2[l] = 1;
      }
      if (!vis[r] && !vis2[r]) {
        add2(S, r, 1);
        vis2[r] = 1;
      }
      if (!vis[u] && !vis2[u]) {
        add2(u, T, 1);
        vis2[u] = 1;
      }
      if (!vis[d] && !vis2[d]) {
        add2(d, T, 1);
        vis2[d] = 1;
      }
      if (!vis[l] && !vis[d]) add2(l, d, 1);
      if (!vis[l] && !vis[u]) add2(l, u, 1);
      if (!vis[r] && !vis[d]) add2(r, d, 1);
      if (!vis[r] && !vis[u]) add2(r, u, 1);
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
  }
  buildgraph();
  long long totalpoint = 0;
  for (int i = 1; i <= 300010; i++) {
    totalpoint += vis2[i];
  }
  printf("%lld", n * m - cnt - (totalpoint - Dinic(S, T)));
  return 0;
}
