#include #include using namespace std; int N, M; char A[102][102]; bool can[102][102]; void Dfs(int x, int y) { if (x > N || y > M) return; if (A[x][y] == '&') return; if (can[x][y]) return; can[x][y] = true; Dfs(x + 1, y); Dfs(x, y + 1); } int main() { cin >> N >> M; for (int i = 1; i <= N; ++i) cin >> (A[i] + 1); Dfs(1, 1); int result = 0; for (int i = 1; i <= N; ++i) for (int j = 1; j <= M; ++j) if (can[i][j]) result = max(result, i + j - 1); cout << result << '\n'; }