#C6429. Asteroid Destruction

    ID: 50188 Type: Default 1000ms 256MiB

Asteroid Destruction

Asteroid Destruction

In a distant galaxy, space debris has resulted in several dangerous asteroids scattered within a grid. Each cell of the grid is either * (indicating an asteroid) or . (empty space). In one move, you can choose any row or any column and destroy all asteroids in that row or column. Formally, let \( R \) be the set of row indices that contain at least one asteroid and \( C \) be the set of column indices that contain at least one asteroid. You are required to determine the minimum number of moves required to destroy all asteroids, i.e. compute \( \min(|R|, |C|) \).

inputFormat

The input begins with a line containing two space-separated integers \( n \) and \( m \) representing the number of rows and columns, respectively. Each of the following \( n \) lines contains a string of length \( m \) representing the grid. Each character in the string is either * (an asteroid) or . (an empty cell).

outputFormat

Output a single integer: the minimum number of moves required to destroy all the asteroids.

## sample
4 5
.*...
....*
.*...
.....
2