Problem:
Score : 300 points

Problem Statement

There are N stones arranged in a row. Every stone is painted white or black.
A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is ., and the stone is black if the character is #.

Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.
Find the minimum number of stones that needs to be recolored.

Constraints

1 \leq N \leq 2\times 10^5

S is a string of length N consisting of . and #.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the minimum number of stones that needs to be recolored.

Sample Input 1

3
#.#

Sample Output 1

1

It is enough to change the color of the first stone to white.

Sample Input 2

5
#.##.

Sample Output 2

2

Sample Input 3

9
.........

Sample Output 3

0

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        //var mod = 998244353;
        var num = Input.num;
        var str = ReadLine();
        var index = 0;
        while (index!=num-1&&str[index] == '.')
        {
            index++;
        }
        var ind = num - 1;
        while (ind != 0 && str[ind] == '#')
        {
            ind--;
        }
        var cb = 0;
        var cw = 0;
        for(var i = index; i <= ind; i++)
        {
            if (str[i] == '#') cb++;
            else cw++;
        }
        WriteLine(Min(cb, cw));
        /*var b = new List<int>();b.Add(0);
        for (var j = index; j < num; j++)
            if (b.Count % 2 == 1 && str[j] == '#')
                b[b.Count - 1]++;
            else if (b.Count % 2 == 0 && str[j] == '.')
                b[b.Count - 1]++;
            else b.Add(0);

        var res = 0;
        for(var i = 0; i < num-1; i++)
        {
            if (str[i] == '#' && str[i + 1] == '.' )
            {
                res++;
                while (i != num - 2 && str[i + 2] == '.')
                {
                    res++;
                    i++;
                }
            }
        }
        WriteLine(res);*/
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}