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>
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int ans = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = getchar();
  return ans;
}
const int mod = 1e9 + 7;
inline int add(const int& a, const int& b) {
  return a + b >= mod ? a + b - mod : a + b;
}
inline int dec(const int& a, const int& b) {
  return a >= b ? a - b : a - b + mod;
}
inline int mul(const int& a, const int& b) { return (long long)a * b % mod; }
inline void Add(int& a, const int& b) {
  a = a + b >= mod ? a + b - mod : a + b;
}
inline void Dec(int& a, const int& b) { a = a >= b ? a - b : a - b + mod; }
inline void Mul(int& a, const int& b) { a = (long long)a * b % mod; }
inline int ksm(int a, int p) {
  int ret = 1;
  for (; p; p >>= 1, a = mul(a, a))
    if (p & 1) Mul(ret, a);
  return ret;
}
const int N = 55;
int n, m, f[N][N][N][N], a[N][N];
char s[N];
inline int dfs(int x1, int y1, int x2, int y2) {
  if (~f[x1][y1][x2][y2]) return f[x1][y1][x2][y2];
  if (x1 > x2 || y1 > y2) return f[x1][y1][x2][y2] = 0;
  if (x1 == x2 && y1 == y2) return f[x1][y1][x2][y2] = a[x1][y1];
  int ret = max(x2 - x1 + 1, y2 - y1 + 1);
  for (register int a = x1; a < x2; ++a)
    ret = min(ret, dfs(x1, y1, a, y2) + dfs(a + 1, y1, x2, y2));
  for (register int b = y1; b < y2; ++b)
    ret = min(ret, dfs(x1, y1, x2, b) + dfs(x1, b + 1, x2, y2));
  return f[x1][y1][x2][y2] = ret;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    for (register int j = 1; j <= n; ++j) a[i][j] = s[j] == '#';
  }
  memset(f, -1, sizeof(f));
  cout << dfs(1, 1, n, n);
  return 0;
}
