import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const W = 0;
const B = 1;

class S {
    public int stone;
    public int count;

    this(int stone, int count) {
        this.stone = stone;
        this.count = count;
    }
}

S[] group(string s) {
    S[] ss;
    int p = 0;
    int stone = -1;
    int count = 0;
    while (p < s.length) {
        int c = s[p] == '.' ? W : B;
        if (stone == c) {
            count++;
        }
        else {
            if (count > 0)
                ss ~= new S(stone, count);

            stone = c;
            count = 1;
        }

        p++;
    }

    if (count > 0)
        ss ~= new S(stone, count);
/*
    foreach (a; ss) {
        writeln(a.stone == W ? "W" : "B", " ", a.count);
    }
*/
    return ss;
}

int calc(string s) {
    S[] ss = group(s);
    int[] ww = new int[ss.length]; // [0, i] を全て W にするコスト
    int[] bb = new int[ss.length]; // [i, $] を全て B にするコスト
    int cost = 0;
    for (int i = 0; i < ss.length; i++) {
        // [0, i] を全て W にするコスト
        if (ss[i].stone == B)
            cost += ss[i].count;
        ww[i] = cost;
    }

    cost = 0;
    for (int i = cast(int)ss.length-1; i >= 0; i--) {
        if (ss[i].stone == W)
            cost += ss[i].count;
        bb[i] = cost;
    }

    int ans = min(ww[$-1], bb[0]);
    for (int i = 0; i < ss.length; i++) {
        // [0, i] を白、[i+1, $-1] を黒にするコスト
        int c = ww[i] + (i + 1 < ss.length ? bb[i + 1] : 0);
        ans = min(ans, c);
    }
    return ans;
}

void main() {
    readint;
    string s = read!string;
    int ans = calc(s);
    writeln(ans);
}
