There is a square grid of size n × n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs max(h, w) to color a rectangle of size h × w. You are to make all cells white for minimum total cost.

Input

The first line contains a single integer n (1 ≤ n ≤ 50) — the size of the square grid.

Each of the next n lines contains a string of length n, consisting of characters '.' and '#'. The j-th character of the i-th line is '#' if the cell with coordinates (i, j) is black, otherwise it is white.

Output

Print a single integer — the minimum total cost to paint all cells in white.

Examples

Input


3
###
#.#
###


Output


3


Input


3
...
...
...


Output


0


Input


4
#...
....
....
#...


Output


2


Input


5
#...#
.#.#.
.....
.#...
#....


Output


5

Note

The examples and some of optimal solutions are shown on the pictures below.

<image>
import java.io.*;
import java.nio.CharBuffer;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class P1199F {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        char[][] grid = new char[n][];
        for (int i = 0; i < n; ++i)
            grid[i] = scanner.next().toCharArray();
        int[][][][] f = new int[n][n][n][n];
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                for (int k = 0; k < n; ++k)
                    Arrays.fill(f[i][j][k], -1);
        writer.println(solve(grid, f, 0, 0, n - 1, n - 1));

        writer.close();
    }

    private static int solve(char[][] grid, int[][][][] f, int r0, int c0, int r1, int c1) {
        if (f[r0][c0][r1][c1] >= 0)
            return f[r0][c0][r1][c1];
        if (r0 == r1 && c0 == c1)
            return f[r0][c0][r1][c1] = grid[r0][c0] == '#' ? 1 : 0;
        f[r0][c0][r1][c1] = Math.max(r1 - r0, c1 - c0) + 1;
        for (int i = r0; i < r1; ++i)
            f[r0][c0][r1][c1] = Math.min(f[r0][c0][r1][c1], solve(grid, f, r0, c0, i, c1) + solve(grid, f, i + 1, c0, r1, c1));
        for (int j = c0; j < c1; ++j)
            f[r0][c0][r1][c1] = Math.min(f[r0][c0][r1][c1], solve(grid, f, r0, c0, r1, j) + solve(grid, f, r0, j + 1, r1, c1));
        return f[r0][c0][r1][c1];
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
