package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	h := scanInt()
	w := scanInt()

	ss := make([]string, h)
	for i := 0; i < h; i++ {
		ss[i] = scanText()
	}

	cost := make([][]int, h)

	for i := 0; i < h; i++ {
		cost[i] = make([]int, w)
		for j := 0; j < w; j++ {
			cost[i][j]=-1
		}
	}

	cnt := 0

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if ss[i][j]=='#' {
				continue
			}

			val := -1

			if i!=0 && cost[i-1][j] !=-1 {
				val = cost[i-1][j]
			}

			// if i!=h-1 {
			// 	val = max(val,cost[i+1][j])
			// }

			if j!=0 && cost[i][j-1]!=-1 {
				if val!=-1 {
					num := cost[i][j-1]

					for l := 0; l < h; l++ {
						for k := 0; k < w; k++ {
							if cost[l][k]==num {
								cost[l][k]=val
							}
						}
					}
				} else {
					val=cost[i][j-1]
				}
			}

			// if j!=w-1 {
			// 	val = max(val,cost[i][j+1])
			// }

			if val==-1 {
				cost[i][j]=cnt
				cnt++
			} else {
				cost[i][j]=val
			}
		}
	}


	ans := -1

	m := make(map[int]int, 0)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			m[cost[i][j]]++
		}
	}

	for _, e := range m {
		ans = max(ans,e)
	}

	fmt.Println(ans-1)


}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] { res = a[i] }
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] { res = a[i] }
	}
	return res
}

