#include <iostream>
#include <string>
#define DN 105
using namespace std;

string v[DN];
int n,m,d[DN][DN],r;

int main() {
  //freopen("input.txt","r",stdin);
  cin>>n>>m;
  for(int i=0; i<n; ++i) cin>>v[i];
  if(v[0][0]=='.') d[0][0]=1;
  else {
    cout<<0;
    return 0;
  }
  for(int i=0; i<n; ++i) for(int j=0; j<m; ++j) 
    if((i || j) && v[i][j]=='.') {
      int rc=0;
      if(i && v[i-1][j]=='.') rc=d[i-1][j]+1;
      if(j && v[i][j-1]=='.') rc=max(rc,d[i][j-1]+1);
      r=max(rc,r);
      d[i][j]=rc;
    }
    cout<<r;
}