#include #include #include using namespace std; string a[150]; int n, m; int sol[150][150]; void readData() { cin >> n >> m; for (int i = 0; i < n; ++i) cin >> a[i]; } int solve() { sol[0][0] = a[0][0] == '&' ? 0 : 1; int max = sol[0][0]; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) { if (i == 0 && j == 0) continue; if (a[i][j] == '&') { sol[i][j] == -1000000; continue; } sol[i][j] = 0; if (i > 0) sol[i][j] = 1 + sol[i-1][j]; if (j > 0) sol[i][j] = std::max(sol[i][j], 1 + sol[i][j-1]); if (sol[i][j] > max) max = sol[i][j]; } return max; } int main() { readData(); cout << solve() << endl; return 0; }