#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class ColoredStrokes { public:
	int getLeast(vector <string> picture) 
	{
		const int H = picture.size();
		const int W = picture[0].size();

		int cnt = 0;
		for(int y=0; y<H; ++y)
		{
			string line = picture[y];
			for(int i=0; i<line.size(); ++i)
				if( line[i]=='G' ) line[i] = 'R';
				else if(line[i]=='B') line[i]='.';
			cnt += howMany('R', line);
		}
		for(int x=0; x<W; ++x)
		{
			string line;
			for(int y=0; y<H; ++y)
				line += picture[y][x];
			for(int i=0; i<line.size(); ++i)
				if( line[i]=='G' ) line[i] = 'B';
				else if(line[i]=='R') line[i]='.';
			cnt += howMany('B', line);
		}
		return cnt;
	}

	int howMany(char c, const string& s)
	{
		int cnt = 0;
		for(int i=0; i<s.size(); )
		{
			while(i<s.size() && s[i]!=c)
				++i;
			if( i == s.size() )
				break;
			++cnt;
			while(i<s.size() && s[i]==c)
				++i;
		}
		return cnt;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, ColoredStrokes().getLeast(picture));}
int main(){

CASE(0)
	string picture_[] = {"...",
 "..."};
	  vector <string> picture(picture_, picture_+sizeof(picture_)/sizeof(*picture_)); 
	int _ = 0; 
END
CASE(1)
	string picture_[] = {"..B.",
 "..B."};
	  vector <string> picture(picture_, picture_+sizeof(picture_)/sizeof(*picture_)); 
	int _ = 1; 
END
CASE(2)
	string picture_[] = {".BB."};
	  vector <string> picture(picture_, picture_+sizeof(picture_)/sizeof(*picture_)); 
	int _ = 2; 
END
CASE(3)
	string picture_[] = {"...B..",
 ".BRGRR",
 ".B.B.."};
	  vector <string> picture(picture_, picture_+sizeof(picture_)/sizeof(*picture_)); 
	int _ = 3; 
END
CASE(4)
	string picture_[] = {"...B..",
 ".BRBRR",
 ".B.B.."};
	  vector <string> picture(picture_, picture_+sizeof(picture_)/sizeof(*picture_)); 
	int _ = 4; 
END
CASE(5)
	string picture_[] = {"GR",
 "BG"};
	  vector <string> picture(picture_, picture_+sizeof(picture_)/sizeof(*picture_)); 
	int _ = 4; 
END
/*
CASE(6)
	string picture_[] = ;
	  vector <string> picture(picture_, picture_+sizeof(picture_)/sizeof(*picture_)); 
	int _ = ; 
END
CASE(7)
	string picture_[] = ;
	  vector <string> picture(picture_, picture_+sizeof(picture_)/sizeof(*picture_)); 
	int _ = ; 
END
*/
}
// END CUT HERE
