#include <cstdio>
const int MAXN = 1000 + 5;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int n, m, ans;
char a[MAXN][MAXN];
void dfs(int x, int y)
{
a[x][y] = '.';
for (int i = 0; i < 4; i++)
{
int nx = x + dx[i], ny = y + dy[i];
if (nx >= 0 && nx < n && ny >= 0 && ny < m && a[nx][ny] == '#')
dfs(nx, ny);
}
}
int main()
{
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
scanf("%c", &a[i][j]);
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (a[i][j] == '#')
{
ans++;
dfs(i, j);
}
if (n)
printf("%s %d %s", "There are ",ans," ships");
else
printf("%s", "Bad placement.");
}