#include <bits/stdc++.h>
using namespace std;
long long n, i, j, ans = 0, m;
char c[100][100], C[100][100];
vector<long long> v;
long long V = 0;
bool visit[100][100];
void coppy(long long I, long long J) {
  V = 0;
  memset(visit, false, sizeof visit);
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) C[i][j] = c[i][j];
  C[I][J] = '.';
}
void dfs(long long x, long long y) {
  if (x < 1 or x > n or y < 1 or y > m) return;
  if (c[x][y] != '#') return;
  visit[x][y] = 1, V++;
  if (!visit[x + 1][y] and c[x + 1][y] == '#') dfs(x + 1, y);
  if (!visit[x - 1][y] and c[x - 1][y] == '#') dfs(x - 1, y);
  if (!visit[x][y - 1] and c[x][y - 1] == '#') dfs(x, y - 1);
  if (!visit[x][y + 1] and c[x][y + 1] == '#') dfs(x, y + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (i = 0; i < 55; i++)
    for (j = 0; j < 55; j++) c[i][j] = '%';
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> c[i][j];
  long long k = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (c[i][j] == '.') continue;
      long long c1 = 0;
      k++;
      if (c[i + 1][j] == '#') c1++;
      if (c[i - 1][j] == '#') c1++;
      if (c[i][j - 1] == '#') c1++;
      if (c[i][j + 1] == '#') c1++;
      v.push_back(c1);
    }
  }
  if (k < 3) return cout << "-1", 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (c[i][j] == '.') continue;
      memset(visit, false, sizeof(visit)), V = 0;
      c[i][j] = '.';
      if (c[i + 1][j] == '#')
        dfs(i + 1, j);
      else if (c[i - 1][j] == '#')
        dfs(i - 1, j);
      else if (c[i][j + 1] == '#')
        dfs(i, j + 1);
      else
        dfs(i, j - 1);
      if (V < k - 1) return cout << 1, 0;
      c[i][j] = '#';
    }
  }
  cout << *min_element(v.begin(), v.end());
}
