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;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a = a % 1000000007;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
      b--;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
long long int n;
vector<vector<char>> grid(50, vector<char>(50));
long long int dp[51][51][51][51];
vector<vector<long long int>> c(50, vector<long long int>(50, 0));
long long int cnt(long long int x1, long long int x2, long long int y1,
                  long long int y2) {
  long long int ans = c[x2 - 1][y2 - 1];
  if (x1 && y1) ans += c[x1 - 1][y1 - 1];
  if (x1) ans -= c[x1 - 1][y2 - 1];
  if (y1) ans -= c[x2 - 1][y1 - 1];
  return ans;
}
long long int solve(long long int x1, long long int x2, long long int y1,
                    long long int y2) {
  if (x1 >= x2 || y1 >= y2) return 0;
  if (dp[x1][x2][y1][y2] != -1) return dp[x1][x2][y1][y2];
  long long int &ans = dp[x1][x2][y1][y2];
  ans = max(x2 - x1, y2 - y1);
  if (cnt(x1, x2, y1, y2) == 0) return ans = 0;
  if (x2 == x1 + 1 && y2 == y1 + 1) return ans = 1;
  if (x2 - x1 >= y2 - y1) {
    for (long long int i = x1; i < x2; i++) {
      if (cnt(i, i + 1, y1, y2) == 0)
        ans = min(ans, solve(x1, i, y1, y2) + solve(i + 1, x2, y1, y2));
    }
  }
  if (x2 - x1 <= y2 - y1) {
    for (long long int i = y1; i < y2; i++) {
      if (cnt(x1, x2, i, i + 1) == 0)
        ans = min(ans, solve(x1, x2, y1, i) + solve(x1, x2, i + 1, y2));
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) cin >> grid[i][j];
  }
  for (long long int i = 0; i <= n; i++) {
    for (long long int j = 0; j <= n; j++) {
      for (long long int k = 0; k <= n; k++) {
        for (long long int l = 0; l <= n; l++) dp[i][j][k][l] = -1;
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (grid[i][j] == '#') c[i][j] = 1;
      if (i) c[i][j] += c[i - 1][j];
      if (j) c[i][j] += c[i][j - 1];
      if (i && j) c[i][j] -= c[i - 1][j - 1];
    }
  }
  long long int ans = solve(0, n, 0, n);
  cout << ans << "\n";
}
