import sys                                                                      
                                                                                
grid = []                                                                       
                                                                                
N = int(raw_input())                                                            
                                                                                
for i in range(0,N):                                                            
    rowChars = list(raw_input())                                                
    rowNums = []                                                                
    for square in rowChars:                                                     
        if square == '.':                                                       
            rowNums.append(0)                                                   
        else:                                                                   
            rowNums.append(1)                                                   
    grid.append(rowNums)                                                        
                                                                                
                                                                                
# Check if totally blank (otherwise there exists a solution)                    
blackSquares = 0                                                                
for i in range(0,N):                                                            
    for j in range(0,N):                                                        
        blackSquares += grid[i][j]                                              
                                                                                
if blackSquares == 0:                                                           
    print "-1"                                                                  
    sys.exit()                                                                  
                                                                                
# Check for all black columns                                                   
colCounts = [0] * N                                                             
for i in range(0,N):                                                            
    for j in range(0,N):                                                        
        colCounts[j] += grid[i][j]                                              
                                                                                
allBlackColCount = 0                                                            
for i in range(0,N):                                                            
    if colCounts[i] == N:                                                       
        allBlackColCount += 1                                                   
                                                                                
# Check for any all black rows
allBlackRowCount = 0                                                            
for i in range(0,N):                                                            
    rowCount = 0                                                                
    for j in range(0,N):                                                        
        rowCount += grid[i][j]                                                  
                                                                                
    if rowCount == N:                                                           
        # Found all black row... we're done                                     
        print "%d" % (N - allBlackColCount)                                     
        sys.exit()                                                              
                                                                                
# No entirely black rows... What we'll do is for each row we will calculate the 
# cost of completing it and take the minimum.                                   
minCost = N                                                                     
for i in range(0,N):                                                            
    blackSquares = 0                                                            
    for j in range(0,N):                                                        
        blackSquares += grid[i][j]                                              
                                                                                
    whiteSquares = N - blackSquares                                             
                                                                                
    completionCost = 0                                                          
    # If the ith column has any black squares, we can use the corresponding row 
    # to fill in the holes in this row for a total number of moves equal to the 
    # number of white squares in the row                                        
    if colCounts[i] > 0:                                                        
        completionCost = whiteSquares                                           
    else:                                                                       
        completionCost = whiteSquares + 1                                       
                                                                                
    minCost = min(minCost, completionCost)                                      
                                                                                
print "%d" % (N - allBlackColCount + minCost)

Measured memory_bytes: 4868