#include #include #include using namespace std; char a[102][102]; int n, m; int dp[103][103]; int main() { // freopen ("b.in", "r", stdin); scanf ("%d %d\n", &n, &m); int i, j; for (i = 1; i <= n; ++i) scanf ("%s\n", a[i] + 1); dp[1][1] = 1; int mx = 1; for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) { if (i == 1 && j == 1) continue; if (a[i][j] == '&') continue; dp[i][j] = -0x3f3f3f3f; if (i - 1 >= 1 && a[i - 1][j] != '&') dp[i][j] = max(dp[i][j], dp[i - 1][j] + 1); if (j - 1 >= 1 && a[i][j - 1] != '&') dp[i][j] = max(dp[i][j], dp[i][j - 1] + 1); if (mx < dp[i][j]) mx = dp[i][j]; } printf ("%d\n", mx); }