#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> c;
int area(int x1, int y1, int x2, int y2) {
  int ans;
  ans = c[x2][y2] - c[x1 - 1][y2] - c[x2][y1 - 1] + c[x1 - 1][y1 - 1];
  return ans;
}
short int dp[101][101][101][101];
int solve(int i, int j, int a, int b) {
  if (dp[i][j][a][b] != -1) return dp[i][j][a][b];
  dp[i][j][a][b] = min(max(a + 1 - i, b + 1 - j), area(i, j, a, b));
  int k;
  for (k = i; k < a; k++)
    dp[i][j][a][b] =
        min((int)dp[i][j][a][b], solve(i, j, k, b) + solve(k + 1, j, a, b));
  for (k = j; k < b; k++)
    dp[i][j][a][b] =
        min((int)dp[i][j][a][b], solve(i, j, a, k) + solve(i, k + 1, a, b));
  return dp[i][j][a][b];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, i, j, k, x, y, m, a, b, ss;
  cin >> n;
  vector<string> s(n);
  for (i = 0; i < n; i++) cin >> s[i];
  c.assign(n + 1, vector<int>(n + 1, 0));
  for (i = 1; i <= n; i++) {
    ss = 0;
    for (j = 1; j <= n; j++) {
      if (s[i - 1][j - 1] == '#') ss++;
      c[i][j] = c[i - 1][j] + ss;
    }
  }
  memset(dp, -1, sizeof(dp));
  int ans = solve(1, 1, n, n);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      for (a = i; a <= n; a++) {
        for (b = j; b <= n; b++) {
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
