#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int n, m, smax, viz[105][105]; char mat[105][105]; void dfs(int x, int y) { viz[x][y] = 1; smax = max(smax, x + y + 1); if(x + 1 < n && mat[x + 1][y] != '&' && !viz[x + 1][y]) { dfs(x + 1, y); } if(y + 1 < m && mat[x][y + 1] != '&' && !viz[x][y + 1]) { dfs(x, y + 1); } } int main() { // freopen("date.in", "r", stdin); // freopen("date.out","w", stdout); cin >> n >> m; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> mat[i][j]; } } if (mat[0][0] == '&') { cout << 0; return 0; } smax = 1; dfs(0, 0); cout << smax; return 0; }