QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 512 MB 總分: 100

#17600. PARKING

统计

The city administration of Zagreb has decided to build a new parking lot. They will use a rectangular plot of land, which we can imagine as a matrix with $N$ rows and $M$ columns. To attract guests and increase revenue, the mayor has decided to place fountains, wells, and other water features on pre-determined squares of the land. The remaining squares are intended for vehicle movement and will be converted into one of two options: parking spaces, or squares for free vehicle movement.

Vehicles can move around the parking lot by moving to an adjacent square in one of the four directions (north, south, east, or west) in each step. The parking lot must be constructed such that at any moment, from every parking space, one can reach the entrance/exit of the parking lot, which is located in the top-left square (at the intersection of the first row and the first column). In other words, vehicles parked in parking spaces must not block the exit for other vehicles. Put differently, every parked vehicle must be able to exit the parking lot without moving other parked vehicles.

Help the mayor determine the maximum possible number of parking spaces for the given land.

Note: The square in the first row and first column is the entrance to the parking lot; it is not intended for parking and will always be free.

Input

The first line contains the natural numbers $N$ and $M$ ($1 \le N \le 6, 1 \le M \le 100$), the number of rows and columns of the land. The next $N$ lines contain $M$ characters each, describing the layout of the land: the character 'x' denotes a square where a fountain will be built, other squares are marked with the character '.' and will be converted for the parking lot.

Output

In a single line, print the required maximum possible number of parking spaces.

Subtasks

Subtask Points Additional Constraints
1 10 $N, M \le 4$
2 10 $N = 2$
3 20 $N = 3$
4 20 $N = 4$
5 20 $N = 5$
6 20 $N = 6$

Examples

Input 1

3 3
...
.x.
...

Output 1

2

Input 2

3 3
...
..x
...

Output 2

4

Input 3

3 6
.x..x.
..x.x.
......

Output 3

3

Input 4

4 5
....x
....x
..x..
.x..x

Output 4

7

Note

Explanation of the fourth example: one possible arrangement of parking spaces:

.PPPx
....x
.Px.P
PxP.x

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.