H, W = map(int, input().split())
S=[['' for i in range(W)] for j in range(H)]
index=[[0 for i in range(W)] for j in range(H)]
LUT = list(range(1))
LUT[0] = 0

for i in range(H):
  column=list(input())
  for j in range(W):
    S[i][j]=column[j]

for i in range(H):
  for j in range(W):
    if S[i][j]==".":
      up=S[i][j-1]
      left=S[i-1][j]
      leftIndex=index[i-1][j]
      upIndex=index[i][j-1]

      #上と左どちらも#の場合
      if up=="#" or j-1<0:
        if left == "#" or i-1<0:
          newIndex = len(LUT)
          LUT.append(newIndex)
          index[i][j] = newIndex
          continue
      #左が白の場合
      if up=="#" or j-1<0:
        if left == ".":
          index[i][j] = leftIndex
          continue

      #上が白の場合
      if up==".":
        if left == "#" or i-1<0:
          index[i][j] = upIndex
          continue

      #上と左どちらも白の場合
      if up=="." and left==".":
        if LUT[upIndex]<LUT[leftIndex]:
          index[i][j] = LUT[upIndex]
          keyLUT = LUT[leftIndex]
          for k in range(len(LUT)):
            if LUT[k]==keyLUT:
              LUT[k] = LUT[upIndex]
        else:
          index[i][j] = LUT[leftIndex]
          keyLUT = LUT[upIndex]
          for k in range(len(LUT)):
            if LUT[k]==keyLUT:
              LUT[k] = LUT[leftIndex]

indexCount = 0;
for i in range(len(LUT)):
  if LUT[i]>indexCount:
    keyLUT = LUT[i]
    indexCount += 1
    for j in range(len(LUT)):
      if LUT[j]==keyLUT:
        LUT[j]=indexCount

for i in range(H):
  for j in range(W):
    index[i][j] = LUT[index[i][j]]

LUTcount=[0 for i in range(len(LUT))]
for i in range(H):
  for j in range(W):
    LUTcount[index[i][j]]+=1
maxIndex=LUTcount.index(max(LUTcount[1:]))
rectLUT=[0,0,0,0]
for i in range(H):
  for j in range(W):
    if index[i][j]==maxIndex:
      rectLUT[0] = i;
      rectLUT[1] = j;
      rectLUT[2] = i;
      rectLUT[3] = j;
for i in range(H):
  for j in range(W):
    if i<rectLUT[0]: rectLUT[0] = i
    if j<rectLUT[1]: rectLUT[1] = j
    if i>rectLUT[2]: rectLUT[2] = i
    if j>rectLUT[3]: rectLUT[3] = j
print(rectLUT)
print((rectLUT[2]-rectLUT[0])+(rectLUT[3]-rectLUT[1]))
