#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int n, m, g;
char c[1013][1013];

map <pair <int, int>, int> pair_po;
map <int, pair <int, int> > po_pair;

int pred[1000013];
int siz[1000013];
int out[1000013];
int color[1013][1013];
int gr[1013][1013];

struct snm {
	void post(int n) {
		for (int i = 0; i < n; i++) {
			pred[i] = i;
			siz[i] = 1;
			out[i] = -1;
		}
	}

	int pr(int a) {
		if (pred[a] == a) {
			return a;
		}
		pred[a] = pr(pred[a]);
		return pred[a];
	}

	void mer(int a, int b) {
		a = pr(a);
		b = pr(b);
		if (siz[a] > siz[b]) {
			swap(a, b);
		}
		out[a] = max(out[a], out[b]);
		out[b] = max(out[b], out[a]);
		siz[b] += siz[a];
		pred[a] = b;
	}
};
void dfs(int x, int y, int gl) {
	if (gr[x][y] == 1) {
		out[pair_po[make_pair(x, y)]] = gl - color[x][y];
		return;
	}
	if (gr[x][y] == 2) {
		return;
	}
	gr[x][y] = 1;
	color[x][y] = gl;
	if (c[x][y] == 'n' || c[x][y] == 'N') {
		dfs(x - 1, y, gl + 1);
	}
	if (c[x][y] == 's' || c[x][y] == 'S') {
		dfs(x + 1, y, gl + 1);
	}
	if (c[x][y] == 'e' || c[x][y] == 'E') {
		dfs(x, y + 1, gl + 1);
	}
	if (c[x][y] == 'w' || c[x][y] == 'W') {
		dfs(x, y - 1, gl + 1);
	}
	gr[x][y] = 2;
}
int main() {
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	//freopen("1.txt", "r", stdin);
	scanf("%d%d%d", &n, &m, &g);
	int ind = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%c", &c[i][j]);
			pair_po[make_pair(i, j)] = ind;
			po_pair[ind] = make_pair(i, j);
			ind++;
		}
	}

	snm s;

	s.post(n * m);


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (gr[i][j] == 0) {
				dfs(i, j, 1);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int v;
			int u = pair_po[make_pair(i, j)];
			if (c[i][j] == 'n' || c[i][j] == 'N') {
				v = pair_po[make_pair(i - 1, j)];
			}
			if (c[i][j] == 's' || c[i][j] == 'S') {
				v = pair_po[make_pair(i + 1, j)];
			}
			if (c[i][j] == 'e' || c[i][j] == 'E') {
				v = pair_po[make_pair(i, j + 1)];
			}
			if (c[i][j] == 'w' || c[i][j] == 'W') {
				v = pair_po[make_pair(i, j - 1)];
			}

			s.mer(u, v);
		}
	}

	int outout = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (c[i][j] > 'z' || c[i][j] < 'a') {
				int zn = pair_po[make_pair(i, j)];
				zn = s.pr(zn);
				if (out[zn] > 0) {
					out[zn] --;
					outout++;
				}
			}
		}
	}

	printf("%d", outout);
	return 0;
}