WHITE = '.'
BLACK = '#'

TOGGLE = {
    WHITE => BLACK,
    BLACK => WHITE
}

def finish?(str)
  str.match(/\A[#{WHITE}]*[#{BLACK}]*\z/)
end

def toggle(str, index)
  tmp = str.dup
  tmp[index] = TOGGLE[str[index]]
  tmp
end

def solve(str, t)
  queue = [[S, 0]]

  while !queue.empty?
    st, ti = queue.shift

    if finish? st
      return ti
    end

    N.times do |i|
      queue.push [toggle(st, i), ti + 1]
    end
  end
end

N = gets.chomp.to_i
S = gets.chomp

puts solve(S, 0)
