/*  -*- coding: utf-8 -*-
 *
 * 2967.cc: AIGo
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

char s[MAX_N + 4], t[MAX_N];
int ls[MAX_N];

/* subroutines */

bool placeable(int i, int m) {
  if (ls[i] > 1) return true;

  if (((i > 0 && t[i - 1] == 'B') ||
       (i > 1 && t[i - 1] == 'W' && t[i - 2] == 'B')) &&
      ((i + 1 < m && t[i + 1] == 'B') ||
       (i + 2 < m && t[i + 1] == 'W' && t[i + 2] == 'B')))
    return false;
  return true;
}

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  int m = 0;
  for (int i = 0; i < n;) {
    int j = i + 1;
    while (j < n && s[i] == s[j]) j++;
    t[m] = s[i];
    ls[m] = j - i;
    m++;
    i = j;
  }
  //printf("m=%d\n", m);
  //for (int i = 0; i < m; i++) printf("%c(%d) ", t[i], ls[i]); putchar('\n');

  int maxl = 0;
  for (int i = 0; i < m; i++)
    if (t[i] == '.' && placeable(i, m)) {
      if (i > 1 && t[i - 1] == 'B' && t[i - 2] == 'W')
	setmax(maxl, ls[i - 1]);
      if (i + 2 < m && t[i + 1] == 'B' && t[i + 2] == 'W')
	setmax(maxl, ls[i + 1]);
    }

  printf("%d\n", maxl);
  return 0;
}

