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>
template <class T>
inline void read(T &);
template <class T>
inline void write(const T &);
typedef const int &ci;
const int iinf = 2147483647;
const long long llinf = 9223372036854775807ll;
using std::abs;
using std::max;
using std::min;
using std::sort;
const int N = 55;
int dfs(int, int, int, int);
int dp[N][N][N][N];
bool a[N][N];
int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      char ch;
      std::cin >> ch;
      a[i][j] = (ch == '#');
    }
  }
  memset(dp, -1, sizeof(dp));
  write(dfs(1, 1, n, n)), putchar('\n');
  return 0;
}
template <class T>
void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!(ch >= '0' && ch <= '9')) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while ((ch >= '0' && ch <= '9')) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template <class T>
void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}
int dfs(int x1, int y1, int x2, int y2) {
  if (~dp[x1][y1][x2][y2]) {
    return dp[x1][y1][x2][y2];
  }
  if (x1 == x2 && y1 == y2) {
    return dp[x1][y1][x2][y2] = a[x1][y1];
  }
  int ans = max(x2 - x1 + 1, y2 - y1 + 1);
  for (int i = x1; i < x2; ++i) {
    ans = min(ans, dfs(x1, y1, i, y2) + dfs(i + 1, y1, x2, y2));
  }
  for (int i = y1; i < y2; ++i) {
    ans = min(ans, dfs(x1, y1, x2, i) + dfs(x1, i + 1, x2, y2));
  }
  return dp[x1][y1][x2][y2] = ans;
}
