This page is still under construction.

Parts of this page are still being built. What you see may change.

Go Board

Time limit1sMemory limit128 MB

Summary
Place black stones on empty cells to capture lone white stones and leave as many empty cells as possible.
Level

Medium7 of 10

Topics
Graph
Solved
No attempts yet

Problem

You are given a Go board of size N×NN \times N. A white stone is written as o, a black stone as x, and an empty point as .. On the board you are given, no two white stones touch up, down, left or right, so every white stone is a group of one.

Hongjun may place as many extra black stones on empty points as he wants. A white stone is captured and taken off the board once all four of its neighbors up, down, left and right are black stones or lie outside the board, and the point it sat on becomes empty. In one small departure from real Go, white never captures black, so a black stone that has been placed stays on the board to the end.

What Hongjun looks at is the number of empty points left at the end. Capturing a white stone turns its point into an empty one, but a point covered by a black stone is no longer empty. So he is stuck on where to play and how many stones to use.

Help Hongjun and write a program that maximizes the number of empty points.

Input

The first line contains the size of the board NN (3≤N≤503 \le N \le 50). Each of the next NN lines contains the state of the board as NN characters. A white stone is o, a black stone is x, and an empty point is .. No two white stones are adjacent up, down, left or right.

Output

Print on the first line the largest number of empty points Hongjun can make.

Examples1

  1. Example 1

    Input
    5
    o.o.o
    .ox..
    oxxxo
    ..x..
    o.o.o
    
    Expected output
    12