import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split;
    auto N = s[0].to!int;
    auto S = s[1].to!(dchar[]);

    bool f(dchar[] T) {
        foreach (i; 0..N) {
            if (T[i] != 'B') continue;
            for (int j = i+1, w = 0; j < N; ++j) {
                if (T[j] == '.') break;
                else if (T[j] == 'W') w += 1;
                else if (T[j] == 'B') {
                    if (w > 0) return true;
                    else break;
                }
            }
        }
        return false;
    }

    int g(dchar[] T) {
        int ans = 0;
        foreach (i; 0..N) {
            if (T[i] != 'W') continue;
            for (int j = i+1, b = 0; j < N; ++j) {
                if (T[j] == '.') break;
                else if (T[j] == 'B') b += 1;
                else if (T[j] == 'W') {
                    ans = max(ans, b);
                    break;
                }
            }
        }
        return ans;
    }

    int ans = 0;
    foreach (i; 0..N) {
        if (S[i] != '.') continue;
        S[i] = 'W';
        if (!f(S)) ans = max(ans, g(S));
        S[i] = '.';
    }

    ans.writeln;
}

