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.util.*;

public class A {

	static int[][][][] memo;
	static int n;
	static char[][] s;

	static int dp(int i1, int i2, int j1, int j2) {

		if (i1 > i2 || j1 > j2)
			return 0;
		if (i1 == i2 && j1 == j2)
			return s[i1][j1] == '#' ? 1 : 0;
		if (memo[i1][j1][i2][j2] != -1)
			return memo[i1][j1][i2][j2];
		int ans = Math.max(i2 - i1 + 1, j2 - j1 + 1);
		if(i1!=i2)
			for (int i = i1; i <= i2; i++)
				ans = Math.min(dp(i1, i - 1, j1, j2) + dp(i + 1, i2, j1, j2) +  dp(i, i, j1, j2), ans);
		if(j1!=j2)
		for (int j = j1; j <= j2; j++)
			ans = Math.min(dp(i1, i2, j1, j - 1) + dp(i1, i2, j + 1, j2) + dp(i1, i2, j, j), ans);
		return memo[i1][j1][i2][j2] = ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		n = sc.nextInt();
		memo = new int[50][50][50][50];
		s = new char[n][n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next().toCharArray();
			for (int j = 0; j < n; j++)
				for (int[] x : memo[i][j])
					Arrays.fill(x, -1);
		}

		out.println(dp(0, n - 1, 0, n - 1));
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}