#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x *= f;
}
const long long M = 659, N = 6e5;
long long n, m, p[M][M], tot, vis[N];
char ch[M][M];
long long first[N], v[N], flow[N], nex[N];
long long s = 0, t = 800, num = 1, cnt = 0;
void add(long long from, long long to, long long val) {
  nex[++num] = first[from];
  first[from] = num;
  v[num] = to;
  flow[num] = val;
}
long long dep[N], q[N], no[N];
bool bfs(long long s, long long t) {
  memset(dep, 0, sizeof(dep));
  memset(q, 0, sizeof(q));
  long long l = 0, r = 1;
  q[1] = s;
  dep[s] = 1;
  no[s] = first[s];
  while (l <= r) {
    long long u = q[++l];
    for (long long i = first[u]; i; i = nex[i]) {
      long long to = v[i];
      if (!dep[to] && flow[i]) {
        no[to] = first[to];
        dep[to] = dep[u] + 1;
        q[++r] = to;
      }
    }
  }
  return dep[t] != 0;
}
long long aim;
long long dfs(long long now, long long fl) {
  if (now == aim) return fl;
  long long f = 0;
  for (long long i = no[now]; i && fl; i = nex[i]) {
    no[now] = i;
    long long to = v[i];
    if (flow[i] && dep[to] == dep[now] + 1) {
      long long x = dfs(to, min(fl, flow[i]));
      flow[i] -= x;
      flow[i ^ 1] += x;
      fl -= x;
      f += x;
    }
  }
  if (!f) dep[now] = -2;
  return f;
}
long long mxflow(long long s, long long t) {
  long long ans = 0;
  aim = t;
  while (bfs(s, t)) {
    ans += dfs(s, 1 << 30);
  }
  return ans;
}
long long sum = 0;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  s = 0;
  t = 90000;
  for (long long i = 1; i <= n; i++) {
    cin >> (ch[i] + 1);
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (ch[i][j] == '#') {
        sum++;
        long long xt = (i - 1) * m + j;
        long long yt = xt + n * m;
        long long gt = i * m + j;
        long long pt = yt - 1;
        if (ch[i - 1][j] == '#' && !vis[xt]) {
          cnt++;
          vis[xt] = 1;
          add(s, xt, 1);
          add(xt, s, 0);
        }
        if (ch[i][j - 1] == '#' && !vis[pt]) {
          cnt++;
          vis[pt] = 1;
          add(pt, t, 1);
          add(t, pt, 0);
        }
        if (ch[i - 1][j] == '#') {
          if (ch[i][j + 1] == '#') {
            add(xt, yt, 1);
            add(yt, xt, 0);
          }
          if (ch[i][j - 1] == '#') {
            add(xt, pt, 1);
            add(pt, xt, 0);
          }
        }
        if (ch[i + 1][j] == '#') {
          if (ch[i][j + 1] == '#') {
            add(gt, yt, 1);
            add(yt, gt, 0);
          }
          if (ch[i][j - 1] == '#') {
            add(gt, pt, 1);
            add(pt, gt, 0);
          }
        }
      }
    }
  }
  cout << sum - (cnt - mxflow(s, t));
  return 0;
}
