#include <bits/stdc++.h>   using namespace std;   const int N = 50 + 5;   int n, dp[N][N][N][N];   char g[N][N];   int dfs(int x, int y, int h, int w) {     if (dp[x][y][h][w] != -1) return dp[x][y][h][w];     if (h == 1 && w == 1) return dp[x][y][h][w] = g[x][y] ==  # ;     if (h == 0 || w == 0) return dp[x][y][h][w] = 0;     dp[x][y][h][w] = max(h, w);     for (int i = 0; i <= h; ++i) {       dp[x][y][h][w] =           min(dp[x][y][h][w], dfs(x, y, i, w) + dfs(x + i, y, h - i, w));     }     for (int j = 0; j <= w; ++j) {       dp[x][y][h][w] =           min(dp[x][y][h][w], dfs(x, y, h, j) + dfs(x, y + j, h, w - j));     }     return dp[x][y][h][w];   }   int main() {     memset(dp, -1, sizeof(dp));     cin >> n;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         cin >> g[i][j];       }     }     printf( %d , dfs(1, 1, n, n));     return 0;   }   