{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [H, W] = r.nn()

    const s: string[][] = []

    for (let i = 0; i < H; i++) {
      s.push(r.s().split(''))
    }
    let s2 = [...s.map(l => [...l])]

    let sy = -1
    let sx = -1

    for (let i = 0; i < H && sx === -1; i++) {
      for (let j = 0; j < W; j++) {
        if (s2[i][j] === '.') {
          sy = i
          sx = j
          break
        }
      }
    }

    let dmaxs: [number, number][] = []
    let dlen = 0

    let queue: [number, number, number][] = [[sy, sx, 0]]

    while (queue.length > 0) {
      const k = queue.shift()

      if (!k) return
      const [y, x, d] = k

      const check = (y, x) => !s2[y] || s2[y][x] !== '.'

      if (!check(y, x - 1)) queue.push([y, x - 1, d + 1])
      if (!check(y, x + 1)) queue.push([y, x + 1, d + 1])
      if (!check(y - 1, x)) queue.push([y - 1, x, d + 1])
      if (!check(y + 1, x)) queue.push([y + 1, x, d + 1])

      s2[y][x] = 'x'
      if (dlen < d) {
        dlen = d
        dmaxs = []
      }
      if (dlen === d) {
        dmaxs.push([y, x])
      }
    }

    dmaxs.forEach(([y, x]) => {
      s2 = [...s.map(l => [...l])]

      queue = [[y, x, 0]]

      while (queue.length > 0) {
        const k = queue.shift()

        if (!k) return
        const [y, x, d] = k

        const check = (y, x) => !s2[y] || s2[y][x] !== '.'

        if (!check(y, x - 1)) queue.push([y, x - 1, d + 1])
        if (!check(y, x + 1)) queue.push([y, x + 1, d + 1])
        if (!check(y - 1, x)) queue.push([y - 1, x, d + 1])
        if (!check(y + 1, x)) queue.push([y + 1, x, d + 1])

        s2[y][x] = 'x'
        if (dlen < d) {
          dlen = d
          dmaxs = []
        }
        if (dlen === d) {
          dmaxs.push([y, x])
        }
      }
    })
    return dlen
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}
