Under construction

Still being built. Things may change

Parking Party

Time limit2sMemory limit1024 MB

Summary
Given a grid with pillars, find the maximum number of cars that can park when each car enters along a row or column from either end.
Level

Medium7 of 10

Topics
Graph, BFS, DFS
Solved
No attempts yet

Problem

Peyman has decided to host a dinner party at his house in Zabol. His house has a rectangular parking lot that can be represented by a grid with nn rows and mm columns. A car can park in one of the n×mn \times m cells. Some cells are occupied by immovable pillars, so no car can park in or pass through them. Each row and each column has an entrance at both of its ends. When a car enters through an entrance, it moves straight forward along that row or column. It stops and parks when it reaches the opposite entrance, or when the next cell is occupied by a pillar or another parked car. A car cannot enter a row or column if its first cell is already occupied.

Peyman wants to park as many cars as possible. He can tell each arriving guest which entrance to take. Help Peyman reach this goal.

Input

The first line contains two integers nn and mm (1≤n,m≤10001 \leq n, m \leq 1000), the number of rows and columns. Each of the next nn lines contains a string of length mm made of "." and "o" characters. The jj-th character of the (i+1)(i+1)-th line is "o" if the cell in row ii and column jj has a pillar, and "." if the cell is empty.

Output

Print a single integer kk, the maximum number of cars Peyman can park in the lot.

Examples2

  1. Example 1

    Input
    3 3
    .o.
    o.o
    .o.
    
    Expected output
    4
    
  2. Example 2

    Input
    3 4
    oooo
    ....
    ...o
    
    Expected output
    7