<== 既然来了就点个小心心再走吧
import java.util.*;
public class Main {
static int[] dx = new int[]{1, 0, -1, 0}, dy = new int[]{0, 1, 0, -1};
static int[] i1 = new int[]{3, 2, 1, 0}, i2 = new int[]{1, 0, 3, 2};
static char[][] c;
static int n,m;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] nums = sc.nextLine().split(" ");
n = Integer.parseInt(nums[0]);
m = Integer.parseInt(nums[1]);
c = new char[n][m];
for(int i = 0;i < n;i++) {
String s = sc.nextLine();
for(int j = 0;j < m;j++) {
c[i][j] = s.charAt(j);
}
}
int res = 0;
for(int i = 0;i < n;i++) {
res = Math.max(res,get(i,0,1));
res = Math.max(res,get(i,m-1,3));
}
for(int i = 0;i < m;i++) {
res = Math.max(res,get(0,i,0));
res = Math.max(res,get(n-1,i,2));
}
System.out.println(res);
}
public static int get(int x, int y, int k) {
int cnt = 0;
while(x >= 0 && x < n && y >= 0 && y < m) {
if(c[x][y] == '/') {
k = i1[k];
} else {
k = i2[k];
}
x += dx[k];
y += dy[k];
cnt++;
}
return cnt;
}
}
tql