#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const int MAX = 1e2 + 13, INF = 1e9 + 13, MAXC = 1e6 + 13;

int n, m, g;

char a[MAX][MAX];

bool used[MAX][MAX];

bool left (int x, int y) {
	return a[x][y] == 'W' || a[x][y] == 'w';
}

bool right(int x, int y) {
	return a[x][y] == 'E' || a[x][y] == 'e';
}

bool up(int x, int y) {
	return a[x][y] == 'N' || a[x][y] == 'n';
}

bool down(int x, int y) {
	return a[x][y] == 'S' || a[x][y] == 's';
}

bool f(int sx, int sy, int vx, int vy) {
	used[vx][vy] = 1;
	if (left(vx, vy)) {
		if (used[vx][vy - 1]) {
			if (vx != sx || vy - 1 != sy) {
				return false;
			} else {
				return true;
			}
		} else {
			return f(sx, sy, vx, vy - 1);
		}
	}
	
	if (right(vx, vy)) {
		if (used[vx][vy + 1]) {
			if (vx != sx || vy + 1 != sy) {
				return false;
			}
			else {
				return true;
			}
		}
		else {
			return f(sx, sy, vx, vy + 1);
		}
	}

	if (up(vx, vy)) {
		if (used[vx - 1][vy]) {
			if (vx - 1 != sx || vy != sy) {
				return false;
			}
			else {
				return true;
			}
		}
		else {
			return f(sx, sy, vx - 1, vy);
		}
	}

	if (down(vx, vy)) {
		if (used[vx + 1][vy]) {
			if (vx + 1 != sx || vy != sy) {
				return false;
			}
			else {
				return true;
			}
		}
		else {
			return f(sx, sy, vx + 1, vy);
		}
	}
}

void z() {
	for (int i = 1; i <= n; i++) {
		memset(used[i], 0, sizeof(used[i]));
	}
	return;
}

int col[MAX][MAX];

int color = 1;

int rob[MAXC];

int cycle[MAXC];

pair<int, int> cs[MAXC], ce[MAXC];

void dfs(int vx, int vy) {
	col[vx][vy] = INF;
	if (left(vx, vy)) {
		if (!col[vx][vy - 1]) {
			dfs(vx, vy - 1);
			col[vx][vy] = col[vx][vy - 1];
			return;
		}
		if (col[vx][vy - 1] == INF) {
			col[vx][vy] = color;
			cs[color] = make_pair(vx, vy - 1);
			ce[color] = make_pair(vx, vy);
			color++;
			return;
		}
		col[vx][vy] = col[vx][vy - 1];
		return;
	}

	if (right(vx, vy)) {
		if (!col[vx][vy + 1]) {
			dfs(vx, vy + 1);
			col[vx][vy] = col[vx][vy + 1];
			return;
		}
		if (col[vx][vy + 1] == INF) {
			col[vx][vy] = color;
			cs[color] = make_pair(vx, vy + 1);
			ce[color] = make_pair(vx, vy);
			color++;
			return;
		}
		col[vx][vy] = col[vx][vy + 1];
		return;
	}

	if (up (vx, vy)) {
		if (!col[vx - 1][vy]) {
			dfs(vx - 1, vy);
			col[vx][vy] = col[vx - 1][vy];
			return;
		}
		if (col[vx - 1][vy] == INF) {
			col[vx][vy] = color;
			cs[color] = make_pair(vx - 1, vy);
			ce[color] = make_pair(vx, vy);
			color++;
			return;
		}
		col[vx][vy] = col[vx - 1][vy];
		return;
	}

	if (down(vx, vy)) {
		if (!col[vx + 1][vy]) {
			dfs(vx + 1, vy);
			col[vx][vy] = col[vx + 1][vy];
			return;
		}
		if (col[vx + 1][vy] == INF) {
			col[vx][vy] = color;
			cs[color] = make_pair(vx + 1, vy);
			ce[color] = make_pair(vx, vy);
			color++;
			return;
		}
		col[vx][vy] = col[vx + 1][vy];
		return;
	}
}

int dl(int vx, int vy, int d) {
	used[vx][vy] = 1;
	if (left(vx, vy)) {
		if (!used[vx][vy - 1])
			return dl(vx, vy - 1, d + 1);
		else
			return d;
	}

	if (right(vx, vy)) {
		if (!used[vx][vy + 1])
			return dl(vx, vy + 1, d + 1);
		else
			return d;
	}

	if (up(vx, vy)) {
		if (!used[vx - 1][vy])
			return dl(vx - 1, vy, d + 1);
		else
			return d;
	}

	if (down(vx, vy)) {
		if (!used[vx + 1][vy])
			return dl(vx + 1, vy, d + 1);
		else
			return d;
	}
}
int main() {
	//freopen("tests.txt", "r", stdin);
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	
	cin >> n >> m >> g;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}

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

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i][j] >= 'A') {
				rob[col[i][j]]++;
			}
		}
	}
	
	int ans = 0;

	for (int i = 1; i < color; i++) {
		cycle[i] = dl(cs[i].first, cs[i].second, 1);
		ans += min(cycle[i], rob[i]);
	}

	cout << ans;
	return 0;
}