#include <bits/stdc++.h>
using namespace std;

int main() {
    int L; string s; cin >> L >> s;

    vector<bool> cannot(L);
    for(int i = 0; i < L; ++i) {
        for(int j = i + 2; j < L; ++j) {
            if(s[i] != 'B' || s[j] != 'B') continue;
            bool found_b = false;
            int cnt = 0;
            for(int k = i + 1; k < j; ++k) {
                found_b |= s[k] == 'B';
                cnt += s[k] == '.';
            }
            if(found_b || cnt != 1) continue;
            for(int k = i + 1; k < j; ++k) {
                cannot[k] = true;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < L; ++i) {
        int tans = 0;
        if(s[i] != '.' || cannot[i]) continue;
        int cnt = 0;
        for(int j = i - 1; j >= 0; --j) {
            if(s[j] == '.') break;
            if(s[j] == 'W') {
                tans += cnt;
                break;
            }
            if(s[j] == 'B') {
                cnt += 1;
            }
        }
        cnt = 0;
        for(int j = i + 1; j < L; ++j) {
            if(s[j] == '.') break;
            if(s[j] == 'W') {
                tans += cnt;
                break;
            }
            if(s[j] == 'B') {
                cnt += 1;
            }
        }
        ans = max(ans, tans);
    }
    cout << ans << endl;
}

