cho.sh
Notes
Loading...

Castle Guards

Time limit

2s

Memory limit

128 MB

Problem

The first floor of a rectangular castle is divided into N rows and M columns. Some cells already contain guards, and the remaining cells are empty.

Add as few guards as possible so that every row and every column contains at least one guard. Given the current state of the castle, find the minimum number of guards that must be added.

Input

The first line contains two natural numbers N and M, the number of rows and columns of the castle.

Each of the next N lines contains a string of length M describing one row. A . means an empty cell, and an X means a cell with a guard.

N and M are at most 50.

Output

Print the minimum number of guards that must be added.