#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#pragma warning(disable : 4996)

using namespace std;

vector<vector<int> > resh(1000000, vector<int> ());
vector<int> used(1000000);
vector<int> used1(1000000);

int h;
int y;
int po;
void dfs(int a) {
	for (int i = 0; i < resh[a].size(); i++) {
		if (used[resh[a][i]] == -1) {
			used[resh[a][i]] = a;
			dfs(resh[a][i]);
		}
		else {
			if (used1[resh[a][i]] != 1) {
				h = -1;
				po = resh[a][i];
			}
		}
		if (h == -1 && a != po) {
			y++;
			used1[a] = 1;
			return;
		}
		if (a == po) {
			h = 0;
			used1[a] = 1;
		}
	}
	used1[a] = 1;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
#endif

	int n, m, g;
	cin >> n >> m >> g;

	vector<vector<char> > mat(n, vector<char>(m));

	int u = 0;
	for(int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> mat[i][j];
			if (mat[i][j] >= 'A' && mat[i][j] <= 'Z') {
				u++;
				mat[i][j] = mat[i][j] - 'A' + 'a';
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (mat[i][j] == 's') {
				resh[i*m + j].push_back((i+1)*m+j);
			}
			if (mat[i][j] == 'n') {
				resh[i*m + j].push_back((i-1)*m + j);
			}
			if (mat[i][j] == 'w') {
				resh[i*m + j].push_back(i*m + j-1);
			}
			if (mat[i][j] == 'e') {
				resh[i*m + j].push_back(i*m + j+1);
			}
		}
	}

	y = 0;
	h = 0;
	po = -1;
	for (int i = 0; i < n*m; i++)
		used[i] = -1;

	int lo = 0;
	for (int i = 0; i < n*m; i++) {
		lo = y;
		if (used[i] == -1) {
			dfs(i);
			if (lo < y)
				y++;
		}
	}

	cout << min(y, u);
	return 0;
}