#include <iostream>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

const int INF = numeric_limits<int>::max() >> 1;

int main()
{
    int n,m; cin>>n>>m;
    
    string s;
    getline(cin,s); // '\n'

    int nrmax=0;
    vector<int> nr(m,-INF);
    nr[0]=0;

    for(int i=0;i<n;++i){
        getline(cin,s);
        for(int j=0;j<m;++j){
            if(s[j]=='&') nr[j]=-INF;
            else{
                nr[j]=1+max(nr[j],nr[j-1]);
                if(nrmax<nr[j]) nrmax=nr[j];
            }
        }
    }

    cout << (nrmax<0?0:nrmax) << '\n'; 
}