#include <bits/stdc++.h>
using namespace std;
bool vis[66][66];
char c[66][66];
int sum;
int n, m;
const int dx[5] = {-1, 1, 0, 0};
const int dy[5] = {0, 0, -1, 1};
int solve(int x, int y) {
  int re = 0;
  for (int i = 0; i < 4; i++) {
    if (c[x + dx[i]][y + dy[i]] == '#') {
      re++;
    }
  }
  return re;
}
void dfs(int x, int y) {
  if (x == 0 || y == 0 || x > n || y > m) {
    return;
  }
  vis[x][y] = true;
  for (int i = 0; i < 4; i++) {
    if (!vis[dx[i] + x][dy[i] + y] && c[dx[i] + x][dy[i] + y] == '#') {
      dfs(x + dx[i], y + dy[i]);
    }
  }
  return;
}
bool Judge(int x, int y) {
  int ii = 0;
  while (c[dx[ii] + x][dy[ii] + y] != '#') {
    ii++;
  }
  dfs(x + dx[ii], y + dy[ii]);
  while (ii != 4) {
    ii++;
    if (c[dx[ii] + x][dy[ii] + y] == '#' && !vis[dx[ii] + x][dy[ii] + y]) {
      return true;
    }
  }
  return false;
}
void Clear() {
  for (int i = 0; i < 66; i++) {
    for (int j = 0; j < 66; j++) {
      vis[i][j] = false;
    }
  }
  return;
}
int main() {
  for (int i = 0; i < 66; i++) {
    for (int j = 0; j < 66; j++) {
      c[i][j] = '.';
    }
  }
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] == '#') {
        sum++;
      }
    }
  }
  if (sum <= 2) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (c[i][j] == '#') {
        c[i][j] = '.';
        if (Judge(i, j)) {
          puts("1");
          return 0;
        }
        c[i][j] = '#';
        Clear();
      }
    }
  }
  int MIN = 5;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (c[i][j] == '#') {
        MIN = min(MIN, solve(i, j));
      }
    }
  }
  cout << MIN << endl;
  return 0;
}
