implicit none
integer n,k,i,slen
integer :: cnt=0,black=0,white=0
character(200000) s
logical :: cnc=.false.


read(5,*) n
read(5,*) s

slen=len_trim(s)

do i=1,slen

if(s(i:i).eq."#") then
black=black+1
else if(s(i:i).eq.".") then
white=white+1 
endif

if(s(i:i+1) .eq. "#.") then
cnc=.true.
else if (s(i:i+1) .eq. ".#" .and.  cnc) then
cnt=cnt+min(black,white)
white=0
black=0
cnc=.false.
endif

enddo

if(s(slen-1:slen).eq."#.") then
cnt=cnt+1
endif

write(6,*) cnt

end