#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
string board[102];
bool vis[102][102];
int n;
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
void bfs(int i, int j) {
queue<pair<int, int>> Q;
Q.push({ i,j });
vis[i][j] = 1;
while (!Q.empty()) {
pair<int, int> cur = Q.front(); Q.pop();
for (int i = 0; i < 4; i++) {
int nx = cur.X + dx[i];
int ny = cur.Y + dy[i];
if (nx<0 || nx>=n || ny<0 || ny>=n)continue;
if (vis[nx][ny] || board[cur.X][cur.Y] != board[nx][ny])continue;
Q.push({ nx,ny });
vis[nx][ny] = 1;
}
}
}
int area() {
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (!vis[i][j]) {
cnt++;
bfs(i, j);
}
}
}
return cnt;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> board[i];
}
int n_rb = area();//적록색맹이 아닌 사람
for (int i = 0; i < n; i++) {
fill(vis[i], vis[i] + n, false);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (board[i][j] == 'R')board[i][j] = 'G';
}
}
int rb = area();
cout << n_rb <<" "<< rb;
}