#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template <typename Flow>
struct residue_edge {
  int to; Flow cap, original_cap; int rev;
  residue_edge(int to, Flow cap, int rev):
    to(to), cap(cap), original_cap(cap), rev(rev){}
};

template <typename Flow>
std::ostream& operator<< (std::ostream& os, const residue_edge<Flow>& e){
  return os
    << "residue_edge{"
    << "to:" << e.to << ","
    << "cap:" << e.cap << ","
    << "rev:" << e.rev
    << "}";
}

template <typename Flow>
struct flow_edge {
  int to; Flow flow;
  flow_edge(int to, Flow flow) : to(to), flow(flow){}
};

template <typename Flow>
std::ostream& operator<< (std::ostream& os, const flow_edge<Flow>& e) {
  return os
    << "flow_edge{"
    << "to:" << e.to << ","
    << "flow:" << e.flow
    << "}";
}

template <typename Flow>
class dinic {
    int                                          n, source, sink;
    std::vector<bool>                            ckd;
    std::vector<int>                             level;
    std::vector<std::vector<residue_edge<Flow>>> graph;

    static constexpr Flow inf_flow = std::numeric_limits<Flow>::max();

    void bfs () {
      std::queue<int> que;
      que.emplace(source); level.at(source) = 0;
      while (!que.empty()) {
        auto crr = que.front(); que.pop();
        for (auto const& e : graph.at(crr)) {
          if (e.cap == 0) continue;
          int nxt = e.to;
          if (level.at(nxt) != -1) continue;
          que.push(nxt);
          level.at(nxt) = level.at(crr) + 1;
        }
      }
    }

    auto dfs (int crr, Flow f = inf_flow) {
      if (crr == sink) return f;
      ckd.at(crr) = true;
      for (auto& e : graph.at(crr)) {
        auto nxt = e.to;
        if (ckd.at(nxt) || e.cap == 0 || level.at(crr) >= level.at(nxt)) continue;
        auto d = dfs(nxt, std::min(f, e.cap));
        if (d > 0) {
          e.cap -= d;
          graph.at(nxt).at(e.rev).cap += d;
          return d;
        }
      }
      level.at(crr) = -1;
      return Flow(0);
    }

  public:
    dinic (int n, int source, int sink):
      n(n), source(source), sink(sink), graph(n){}

    void insert(int u, int v, Flow c) {
      // debug(u, v, c);
      graph.at(u).emplace_back(v, c, graph.at(v).size());
      graph.at(v).emplace_back(u, 0, graph.at(u).size() - 1);
    }

    auto build() {
      Flow ret = 0;
      while (true) {
        level.assign(n, -1);
        bfs();
        if (level.at(sink) == -1) return ret;
        ckd.assign(n, false);
        while (true) {
          auto f = dfs(source);
          if (f == 0) break;
          ret += f;
        }
      }
    }

    auto collect() const {
      std::vector<std::vector<flow_edge<Flow>>> ret(n);
      for (auto i = 0; i < n; i++) {
        for (auto const& e : graph.at(i)) {
          auto flow = e.original_cap - e.cap;
          if (flow > 0) ret.at(i).emplace_back(e.to, flow);
        }
      }
      return ret;
    }
};

template <typename T>
auto make_vector_impl(size_t sz, T t) {return std::vector<T>(sz, t);}

template <size_t N, typename T, typename U, std::enable_if_t<N == 1, std::nullptr_t> = nullptr>
auto make_vector(size_t sz, U u) {return make_vector_impl(sz, T(u));}

template <size_t N, typename T, std::enable_if_t<N == 1, std::nullptr_t> = nullptr>
auto make_vector(size_t sz) {return std::vector<T>(sz);}

template <size_t N, typename T, typename... Args, std::enable_if_t<N != 1, std::nullptr_t> = nullptr>
auto make_vector(size_t a, Args... args) {return make_vector_impl(a, make_vector<N - 1, T>(args...));}

template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {return t.at(i);}

template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {return at(t.at(i), args...);}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int h, w; std::cin >> h >> w;
  auto n = h * w;
  auto N = 4 * n;
  auto s = n, t = n + 1;
  auto dnc = dinic< int >(N, s, t);
  auto grid = make_vector< 2, int >(h, w);
  auto encode = [&] (auto i, auto j)
    { return i * w + j; };

  rep(i, 0, h) rep(j, 0, w) {
    char c; std::cin >> c;
    at(grid, i, j) = c == '#';
    if (at(grid, i, j)) {
      dnc.insert(s, encode(i, j), 1);
      dnc.insert(encode(i, j), t, 1);
    }
  }

  constexpr int inf = 1 << 30;
  auto now = n + 2;
  auto sandal = 0;

  // horizontal
  rep(i, 0, h) rep(j, 0, w - 1) {
    if (at(grid, i, j) && at(grid, i, j + 1)) {
      sandal++;
      auto x = encode(i, j);
      auto y = encode(i, j + 1);
      auto z = now++;
      dnc.insert(s, z, 1);
      dnc.insert(z, x, inf);
      dnc.insert(z, y, inf);
      dnc.insert(z, t, 0);
    }
  }

  // vertical
  rep(i, 0, h - 1) rep(j, 0, w) {
    if (at(grid, i, j) && at(grid, i + 1, j)) {
      sandal++;
      auto x = encode(i, j);
      auto y = encode(i + 1, j);
      auto z = now++;
      dnc.insert(s, z, 0);
      dnc.insert(x, z, inf);
      dnc.insert(y, z, inf);
      dnc.insert(z, t, 1);
    }
  }
  auto ret = dnc.build() - sandal;
  std::cout << ret << std::endl;
  return 0;
}



Measured memory_bytes: 3396