#pragma comment(linker, "/stack:536870912")
#include <fstream>
#include <vector>
#include <algorithm>

#define MAXN 1000

using namespace std;


vector<int> robNum(1);
vector<int> Len(1);
vector<int> Unit[2];
char field[MAXN][MAXN];
bool robots[MAXN][MAXN];
bool used[MAXN][MAXN];
int comps[MAXN][MAXN];
int n, m, g;

void FindComps(int i, int j, int cmp)
{
	if (comps[i][j])
		return;
	comps[i][j] = cmp;
	if (robots[i][j])
		robNum[cmp]++;
	if (i > 0 && (field[i][j] == 'n' || field[i - 1][j] == 's'))
		FindComps(i - 1, j, cmp);
	if (i < n - 1 && (field[i][j] == 's' || field[i + 1][j] == 'n'))
		FindComps(i + 1, j, cmp);
	if (j > 0 && (field[i][j] == 'w' || field[i][j - 1] == 'e'))
		FindComps(i, j - 1, cmp);
	if (j < m - 1 && (field[i][j] == 'e' || field[i][j + 1] == 'w'))
		FindComps(i, j + 1, cmp);
}

int I, J, NUM;

void Dfs(int i, int j)
{
	if (used[i][j])
	{
		I = i;
		J = j;
		NUM = 1;
		return;
	}
	used[i][j] = true;
	if (i > 0 && field[i][j] == 'n')
		Dfs(i - 1, j);
	if (i < n - 1 && field[i][j] == 's')
		Dfs(i + 1, j);
	if (j > 0 && field[i][j] == 'w')
		Dfs(i, j - 1);
	if (j < m - 1 && field[i][j] == 'e')
		Dfs(i, j + 1);
	if (I == i && J == j)
		Len[comps[i][j]] = NUM;
	NUM++;
}

int main()
{
	ifstream fin("robots.in");
	ofstream fout("robots.out");
	fin >> n >> m >> g;
	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			fin >> field[i][j];
			if (field[i][j] < 'a')
			{
				robots[i][j] = 1;
				field[i][j] += 32;
			}
		}
	int col = 1;
	Unit[0].push_back(-1);
	Unit[1].push_back(-1);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (!comps[i][j])
			{
				robNum.push_back(0);
				Len.push_back(0);
				Unit[0].push_back(i);
				Unit[1].push_back(j);
				FindComps(i, j, col++);
			}
	for (int i = 1; i < Unit[0].size(); i++)
	{
		I = J = -1;
		NUM = 0;
		Dfs(Unit[0][i], Unit[1][i]);
	}
	for (int i = 1; i < robNum.size(); i++)
		ans += min(robNum[i], Len[i]);
	fout << ans;
	fout << endl << (512LL * 1024LL * 1024LL);
	return 0;
}