#include <bits/stdc++.h>
using namespace std;
const int maxnode = 30000 + 5;
const int maxedge = 2100000 + 5;
const int oo = 1000000000;
int node, src, dest, nedge;
int head[maxnode], point[maxedge], nxt[maxedge], flow[maxedge], capa[maxedge];
int dist[maxnode], Q[maxnode], work[maxnode];
void init(int _node, int _src, int _dest) {
  node = _node;
  src = _src;
  dest = _dest;
  for (int i = 0; i < node; i++) head[i] = -1;
  nedge = 0;
}
void addedge(int u, int v, int c1, int c2) {
  point[nedge] = v, capa[nedge] = c1, flow[nedge] = 0, nxt[nedge] = head[u],
  head[u] = (nedge++);
  point[nedge] = u, capa[nedge] = c2, flow[nedge] = 0, nxt[nedge] = head[v],
  head[v] = (nedge++);
}
bool dinic_bfs() {
  memset(dist, 255, sizeof(dist));
  dist[src] = 0;
  int sizeQ = 0;
  Q[sizeQ++] = src;
  for (int cl = 0; cl < sizeQ; cl++)
    for (int k = Q[cl], i = head[k]; i >= 0; i = nxt[i])
      if (flow[i] < capa[i] && dist[point[i]] < 0) {
        dist[point[i]] = dist[k] + 1;
        Q[sizeQ++] = point[i];
      }
  return dist[dest] >= 0;
}
int dinic_dfs(int x, int exp) {
  if (x == dest) return exp;
  for (int &i = work[x]; i >= 0; i = nxt[i]) {
    int v = point[i], tmp;
    if (flow[i] < capa[i] && dist[v] == dist[x] + 1 &&
        (tmp = dinic_dfs(v, min(exp, capa[i] - flow[i]))) > 0) {
      flow[i] += tmp;
      flow[i ^ 1] -= tmp;
      return tmp;
    }
  }
  return 0;
}
int dinic_flow() {
  int result = 0;
  while (dinic_bfs()) {
    for (int i = 0; i < node; i++) work[i] = head[i];
    while (1) {
      int delta = dinic_dfs(src, oo);
      if (delta == 0) break;
      result += delta;
    }
  }
  return result;
}
char G[50][51];
int n, m;
int id[50][50], N;
int dx[] = {1, 0}, dy[] = {0, 1};
vector<int> adj[50 * 50 + 3];
int main() {
  scanf("%d %d", &m, &n);
  for (int i = 0; i < (m); i++) {
    scanf("%s", G[i]);
    for (int j = 0; j < (n); j++)
      if (G[i][j] == '#') id[i][j] = ++N;
  }
  if (N <= 2) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (n); j++)
      if (id[i][j]) {
        for (int k = 0; k < (2); k++) {
          int nx = i + dx[k], ny = j + dy[k];
          if (nx == m || ny == n) continue;
          if (id[nx][ny]) {
            adj[id[i][j]].push_back(id[nx][ny]);
            adj[id[nx][ny]].push_back(id[i][j]);
          }
        }
      }
  int ans = INT_MAX;
  for (int i = (2); i <= (N); i++) {
    init(2 * N + 2, N + 1, i);
    for (int j = (2); j <= (N); j++) addedge(j, j + N, 1, 0);
    for (int u = (1); u <= (N); u++)
      for (int v : adj[u]) addedge(u + N, v, 1, 0);
    ans = min(ans, dinic_flow());
  }
  cout << ans << endl;
  return 0;
}
