#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>;
#include <algorithm>;
#include <vector>;
using namespace std;
char map[1001][1001];
int used[1001][1001] = { 0 };
int used1[1001][1001] = { 0 };
pair<int, int> qwe = make_pair(0, 0);
pair<int, int> mapans[1001][1001];
bool flag = false, flag1 = false, flag2 = true, superflag = true, flag228 = true;
int x, y;
int len = 0, answer = 0;
int func(int i, int j, int u) {
	if(!flag){
		if (used[i][j] > 0) {
			flag = true;
			len = u + 1 - used[i][j];
			return 0;
		}
		used[i][j] = u + 1;
		if ((map[i][j] == 'n') || (map[i][j] == 'N')) {
			func(i - 1, j, u + 1);
		}
		else if ((map[i][j] == 's') || (map[i][j] == 'S')) {
			func(i + 1, j, u + 1);
		}
		else if ((map[i][j] == 'e') || (map[i][j] == 'E')) {
			func(i, j + 1, u + 1);
		}
		else if ((map[i][j] == 'w') || (map[i][j] == 'W')) {
			func(i, j - 1, u + 1);
		}
	}
	if (flag) {
		if (!superflag)return 0;
		if (!flag2)flag228 = false;
		if (flag2) {
			x = i;
			y = j;
			if ((map[i][j] == 'n') || (map[i][j] == 'N')) {
				x = i - 1;
			}
			else if ((map[i][j] == 's') || (map[i][j] == 'S')) {
				x = i + 1;
			}
			else if ((map[i][j] == 'e') || (map[i][j] == 'E')) {
				y = j + 1;
			}
			else if ((map[i][j] == 'w') || (map[i][j] == 'W')) {
				y = j - 1;
			}
			if ((mapans[i][j].first < mapans[i][j].second) || (mapans[i][j] == qwe)) {
				answer++;
			}
			flag2 = false;
		}
		if ((mapans[i][j].first < mapans[i][j].second)||(mapans[i][j] == qwe)) {
			flag1 = true;
			if (mapans[i][j] == qwe) {
				mapans[i][j].second = len;
				mapans[i][j].first = 1;
			}
			else {
				if ((i != x) || (j != y) || (flag2))mapans[i][j].first++;
			}
		}
		if ((i == x) && (j == y))superflag = false;
		return 0;
	}
	return 0;
}
int main() {
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	int n, m, g;
	scanf("%d%d%d\n", &n, &m, &g);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%c", &map[i][j]);
		}
		scanf("\n");
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			mapans[i][j] = qwe;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			flag = false;
			flag1 = false;
			flag2 = true;
			superflag = true;
			flag228 = true;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					used[i][j] = 0;
				}
			}
			if ((map[i][j] == 'N') || (map[i][j] == 'S') || (map[i][j] == 'E') || (map[i][j] == 'W')) {
				func(i, j, 0);
			}
		}
	}
	printf("%d", answer-1);
}