시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB228844.444%

문제

Consider a maze marked with row and column numbers:

   1 2 3 4 5 6 7
  +-+-+-+-+-+-+-+
1 |           |
  + +-+-+-+-+-+ +
2 |             |
  + +-+-+-+-+-+ +
3 | |   |   | | |
  + +-+ + +-+ + +
4 | |     |     |
  +-+-+-+-+-+-+-+

This maze has one exit (right hand side, first row). It is possible to reach the exit from many locations in the maze but not all of them (for instance, row 4, column 2).

Your task is to decide how many cells are isolated from an exit.

입력

  • Line 1: two space-separated integers R,C (1 ≤ R,C ≤ 35) that tell the number of rows and columns for the maze
  • Lines 2..2*R+2: An ASCII map of the matrix just as above. Walls are marked by '_' and '|'. Wall intersections (and potential wall intersections) are marked by '+'.

출력

On a single line, output one integer that tells the number of cells from which one can not find a way to exit the maze.

예제 입력 1

4 7
+-+-+-+-+-+-+-+
|           |
+ +-+-+-+-+-+ +
|             |
+ +-+-+-+-+-+ +
| |   |   | | |
+ +-+ + +-+ + +
| |     |     |
+-+-+-+-+-+-+-+

예제 출력 1

7