h,w,*S = $<.read.split
H,W = h.to_i, w.to_i
S.each {|s| s << "#"}
S << "#"*W
A = (T=H*W).times.map {|i| Array.new(T-i)}
h,w = 0,-1
T.times {|i|
  h+=1 and w=0  if W == w+=1
  a,s = A[i],S[h]
  next if s[w]==?#
  a[0] = 0
  a[1] = 1  if s[w+1]==?.
  a[W] = 1  if S[h+1][w]==?.
}
kh,kw = 0,-1
T.times {|k|
  kh+=1 and kw=0  if W == kw+=1
  next  if S[kh][kw] == ?#
  ih,iw = 0,-1
  T.times {|i|
    ih+=1 and iw=0  if W == iw+=1
    next  if S[ih][iw] == ?# || i==k
    x = i<k ? A[i][k-i] : A[k][i-k] or next
    jh,jw = ih,iw
    (i+1...T).each {|j|
      jh+=1 and jw=0  if W == jw+=1
      next  if S[jh][jw] == ?# || j==k
      next  if x >= y =  A[i][j-i]||0xfff
      next  if y <= z = ((j<k ? A[j][k-j] : A[k][j-k])||0xfff) + x
      A[i][j-i] = z
    }
  }
}
p A.flatten.max_by {|x|x||0}