#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]; } const int inf = 1000000; int solve() { sol[0][0] = (a[0][0] == '&' ? -inf : 1); int res = 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] = -inf; continue; } sol[i][j] = -inf; if (i > 0) sol[i][j] = std::max(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] > res) res = sol[i][j]; } return res > 0 ? res : 0; } int main() { readData(); cout << solve() << endl; return 0; }