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>
/*input
 
5
#...#
.#.#.
.....
.#...
#....



*/
import java.io.*;
import java.util.*;

 
public class mymy
{
 
	static OutputStream outputStream = System.out;
	static PrintWriter out = new PrintWriter(outputStream);
	static InputStream inputStream = System.in;
	static InputReader br = new InputReader(inputStream);

	static int n;
	

	static int[][] a;

	static int[][][][] dp;



	static int find(int x1,int y1,int x2,int y2)
	{
		if(x1==x2 && y1==y2) return a[x1][y1];

		if(dp[x1][y1][x2][y2]!=-1) return dp[x1][y1][x2][y2];

		int ans=Math.max(x2-x1+1,y2-y1+1);

		for(int tmp=x1;tmp<x2;tmp++) ans=Math.min(ans,find(x1,y1,tmp,y2)+find(tmp+1,y1,x2,y2));

		for(int tmp=y1;tmp<y2;tmp++) ans=Math.min(ans,find(x1,y1,x2,tmp)+find(x1,tmp+1,x2,y2));

		return dp[x1][y1][x2][y2]=ans;
	}


	

	public static void main(String[] args)throws IOException
	{
		
 		n=br.nextInt();

 		a=new int[n][n];

 		dp=new int[n][n][n][n];

 		for(int i=0;i<n;i++)
 		{
 			String s=br.next();
 			for(int j=0;j<n;j++)
 			{
 				if(s.charAt(j)=='#') a[i][j]=1;

 				for(int k=0;k<n;k++) Arrays.fill(dp[i][j][k],-1);
 			}
 		}

 		out.println(find(0,0,n-1,n-1));





 
		out.close();
 
	}





















	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
 
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
 
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
 
	}
	
}