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

struct Dinic {
    struct edge {
        int to, cap, rev;
    };

    int n;
    vector<vector<edge>> G;
    vector<int> level;
    vector<int> iter;

    void bfs(int s) {
        level.assign(n, -1);
        queue<int> que;
        que.push(s);
        level[s] = 0;
        while (que.size()) {
            int v = que.front();
            que.pop();
            for (int i = 0; i < G[v].size(); i++) {
                edge &e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int i = iter[v]; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    Dinic(int n) : n(n), G(n), level(n), iter(n) {}

    void add_edge(int from, int to, int cap) {
        G[from].push_back({to, cap, int(G[to].size())});
        G[to].push_back({from, 0, int(G[from].size()) - 1});
    }

    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            bfs(s);
            if (level[t] < 0) return flow;
            iter.assign(n, 0);
            int f;
            while ((f = dfs(s, t, 1e9)) > 0) {
                flow += f;
            }
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<string> board(n);
    for (int i = 0; i < n; i++) cin >> board[i];
    vector<int> as, bs, cs;
    auto push = [&](int a, int b, int c) {
        as.push_back(a);
        bs.push_back(b);
        cs.push_back(c);
    };
    int N = n * m + 2;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (board[i][j] == '#') {
                push(n * m, i * m + j, 1);
                push(i * m + j, n * m + 1, 1);
            }
        }
    }
    int dx[] = {1, 0};
    int dy[] = {0, 1};
    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (board[i][j] == '.') continue;
            for (int k = 0; k < 2; k++) {
                int x = i + dx[k], y = j + dy[k];
                if (x < n && y < m) {
                    if (board[x][y] == '#') {
                        if (k) {
                            sum++;
                            push(i * m + j, N, 1e9);
                            push(x * m + y, N, 1e9);
                            push(N, n * m + 1, 1);
                            N++;
                        } else {
                            sum++;
                            push(N, i * m + j, 1e9);
                            push(N, x * m + y, 1e9);
                            push(n * m, N, 1);
                            N++;
                        }
                    }
                }
            }
        }
    }
    Dinic dinic(N);
    for (int i = 0; i < as.size(); i++) {
        dinic.add_edge(as[i], bs[i], cs[i]);
    }
    cout << dinic.max_flow(n * m, n * m + 1) - sum << endl;
}


Measured memory_bytes: 3460