{"raw_statement":[{"iden":"problem statement","content":"There is an $N \\times M$ grid and a player standing on it.  \nLet $(i,j)$ denote the square at the $i$\\-th row from the top and $j$\\-th column from the left of this grid.  \nEach square of this grid is ice or rock, which is represented by $N$ strings $S_1,S_2,\\dots,S_N$ of length $M$ as follows:\n\n*   if the $j$\\-th character of $S_i$ is `.`, square $(i,j)$ is ice;\n*   if the $j$\\-th character of $S_i$ is `#`, square $(i,j)$ is rock.\n\nThe outer periphery of this grid (all squares in the $1$\\-st row, $N$\\-th row, $1$\\-st column, $M$\\-th column) is rock.\nInitially, the player rests on the square $(2,2)$, which is ice.  \nThe player can make the following move zero or more times.\n\n*   First, specify the direction of movement: up, down, left, or right.\n*   Then, keep moving in that direction until the player bumps against a rock. Formally, keep doing the following:\n    *   if the next square in the direction of movement is ice, go to that square and keep moving;\n    *   if the next square in the direction of movement is rock, stay in the current square and stop moving.\n\nFind the number of ice squares the player can touch (pass or rest on)."},{"iden":"constraints","content":"*   $3 \\le N,M \\le 200$\n*   $S_i$ is a string of length $M$ consisting of `#` and `.`.\n*   Square $(i, j)$ is rock if $i=1$, $i=N$, $j=1$, or $j=M$.\n*   Square $(2,2)$ is ice."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $M$\n$S_1$\n$S_2$\n$\\vdots$\n$S_N$"},{"iden":"sample input 1","content":"6 6\n######\n#....#\n#.#..#\n#..#.#\n#....#\n######"},{"iden":"sample output 1","content":"12\n\nFor instance, the player can rest on $(5,5)$ by moving as follows:\n\n*   $(2,2) \\rightarrow (5,2) \\rightarrow (5,5)$.\n\nThe player can pass $(2,4)$ by moving as follows:\n\n*   $(2,2) \\rightarrow (2,5)$, passing $(2,4)$ in the process.\n\nThe player cannot pass or rest on $(3,4)$."},{"iden":"sample input 2","content":"21 25\n#########################\n#..............###...####\n#..............#..#...###\n#........###...#...#...##\n#........#..#..#........#\n#...##...#..#..#...#....#\n#..#..#..###...#..#.....#\n#..#..#..#..#..###......#\n#..####..#..#...........#\n#..#..#..###............#\n#..#..#.................#\n#........##.............#\n#.......#..#............#\n#..........#....#.......#\n#........###...##....#..#\n#..........#..#.#...##..#\n#.......#..#....#..#.#..#\n##.......##.....#....#..#\n###.............#....#..#\n####.................#..#\n#########################"},{"iden":"sample output 2","content":"215"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}