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 i8 = char;
using u8 = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = int;
using u32 = unsigned int;
using i64 = long long int;
using u64 = unsigned long long int;
using f32 = float;
using f64 = double;
using f80 = long double;
const i64 MOD = 1000000007;
const f64 EPS = 1e-9;
inline i64 fast_pow(i64 a, i64 b) {
  i64 ans = 1, base = a;
  while (b) {
    if (b & 1) {
      ans = (ans * base) % MOD;
    }
    base = (base * base) % MOD;
    b >>= 1;
  }
  return ans;
}
using namespace std;
i64 dp[50][50][50][50];
string m[50];
i64 rec(i64 x1, i64 y1, i64 x2, i64 y2) {
  if (dp[x1][y1][x2][y2] != -1) {
    return dp[x1][y1][x2][y2];
  }
  if (x1 == x2 && y1 == y2) {
    return dp[x1][y1][x2][y2] = (m[x1][y1] == '#' ? 1 : 0);
  }
  i64 res = max(x2 - x1 + 1, y2 - y1 + 1);
  for (i64 i = x1; i < x2; ++i) {
    i64 res_left = rec(x1, y1, i, y2);
    i64 res_right = rec(i + 1, y1, x2, y2);
    res = min(res, res_left + res_right);
  }
  for (i64 i = y1; i < y2; ++i) {
    i64 res_up = rec(x1, y1, x2, i);
    i64 res_down = rec(x1, i + 1, x2, y2);
    res = min(res, res_up + res_down);
  }
  return dp[x1][y1][x2][y2] = res;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  i64 n;
  cin >> n;
  for (i64 i = 0; i < n; ++i) {
    cin >> m[i];
  }
  for (i64 i = 0; i < n; ++i)
    for (i64 j = 0; j < n; ++j)
      for (i64 k = 0; k < n; ++k)
        for (i64 l = 0; l < n; ++l) dp[i][j][k][l] = -1;
  cout << rec(0, 0, n - 1, n - 1) << endl;
  return 0;
}
