main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  _ <- getLine                                                                                                                                        
  s <- reverse . dropWhile (=='#') . reverse . dropWhile (=='.') <$> getLine                                                                          
  let w = length . filter (=='.') $ s                                                                                                                 
  print $ minimum $ map (uncurry (+)) $ solve s 0 w                                                                                                   
                                                                                                                                                      
solve :: String -> Int -> Int -> [(Int,Int)]                                                                                                          
solve [] a b = [(a,b)]                                                                                                                                
solve [x] a b                                                                                                                                         
  | x == '#' = [(a+1,b)]                                                                                                                              
  | x == '.' = [(a,b-1)]                                                                                                                              
solve (x:y:xs) a b                                                                                                                                    
  | x == '.' = solve (y:xs) a (b-1)                                                                                                                   
  | x == '#' && y == '#' = solve (y:xs) (a+1) b                                                                                                       
  | x == '#' && y == '.' = (a,b) : solve (y:xs) (a+1) b