package main import ( "bufio" "fmt" "math" "os" ) func main() { var h, w int fmt.Scanf("%d %d", &h, &w) dp := [][]int{} for i := 0; i <= h; i++ { dp = append(dp, make([]int, w+1)) } max := 0 sc := bufio.NewScanner(os.Stdin) for y := 1; y <= h; y++ { sc.Scan() row := sc.Text() for x := 1; x <= w; x++ { if row[x-1:x] == "." { continue } dp[y][x] = minInt(dp[y-1][x-1], dp[y-1][x], dp[y][x-1]) + 1 max = maxInt(max, dp[y][x]) } } fmt.Println((max + 1) / 2) } func maxInt(list ...int) int { max := int(math.MinInt64) for _, i := range list { if i > max { max = i } } return max } func minInt(list ...int) int { min := int(math.MaxInt64) for _, i := range list { if i < min { min = i } } return min }