n = gets.to_i - 1 s = gets.chomp m = s.size l = -1 n.times do |i| if s[i] == ?# l = i break end end r = -1 (m-1).downto(n+1) do |i| if s[i] == ?# r = i break end end ans = 1000000000 if l != -1 ans1 = 0 s1 = ?. * m l.upto(n-1) do |i| s1[i] = ?# ans1 += 1 end cnt = 0 m.times do |i| if s[i] != s1[i] cnt += 1 end end (l + 1).upto(m - 1) do |i| if cnt == 0 break end s1[i] = (s1[i] == ?. ? ?# : ?.) ans1 += 1 if s1[i] != s[i] ans1 += 2 s1[i] = s[i] s1[i + 1] = (s1[i + 1] == ?. ? ?# : ?.) if s1[i + 1] == s[i + 1] cnt -= 1 else cnt += 1 end else cnt -= 1 end end ans = [ans, ans1].min end if r != -1 ans2 = 0 s2 = ?. * m r.downto(n+1) do |i| s2[i] = ?# ans2 += 1 end cnt = 0 m.times do |i| if s[i] != s2[i] cnt += 1 end end (r - 1).downto(0) do |i| if cnt == 0 break end s2[i] = (s2[i] == ?. ? ?# : ?.) ans2 += 1 if s2[i] != s[i] ans2 += 2 s2[i] = s[i] s2[i - 1] = (s2[i - 1] == ?. ? ?# : ?.) if s2[i - 1] == s[i - 1] cnt -= 1 else cnt += 1 end else cnt -= 1 end end ans = [ans, ans2].min end p ans