<?php
$n = (int)trim(fgets(STDIN));
$s = trim(fgets(STDIN));

$stack = new SimpleStack();
for ($i=0; $i < $n; $i++) { 
	$tmp = $s[$i];
	if ($tmp === '#') {
		$stack->push('B');
	}else{
		if ($stack->isEmpty()) {
			$stack->push('W');
		}else{
			$prev = $stack->pop();
			if ($prev === 'W') {
				$stack->push('W');
				$stack->push('W');
			}else{
				$prev2 = $stack->pop();
				if(empty($prev2)){
					$stack->push('W');
				}else{
					$stack->push($prev2);
					$stack->push($prev2);
				}
			}
		}
	}
}
$res = [];
while (!$stack->isEmpty()) {
	$res[] = $stack->pop();
}
echo $n - count($res);


/**
 * 
 */
class SimpleStack
{
	private $idx = 0;
	private $data = [];

	function push($d){
		$this->idx += 1;
		$this->data[$this->idx] = $d;
	}
	function pop(){
		$d = null;
		if (!$this->isEmpty()) {
			$d = $this->data[$this->idx];
			$this->idx -= 1;
		}
		return $d;
	}
	function isEmpty(){
		return $this->idx === 0;
	}
}