#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#define ll long long
using namespace std;
int cycle;
vector<vector<int> > dir, rob, u;
struct pnt {
	int x, y;
	pnt(int x, int y) {
		this->x = x;
		this->y = y;
	}
	void move() {
		int tox = x, toy = y;
		if (dir[x][y] == 1) tox--;
		if (dir[x][y] == 2) toy--;
		if (dir[x][y] == 3) tox++;
		if (dir[x][y] == 4) toy++;
		x = tox, y = toy;
	}
	void move1() {
		int tox = x, toy = y;
		if (dir[x][y] == 3) tox--;
		if (dir[x][y] == 4) toy--;
		if (dir[x][y] == 1) tox++;
		if (dir[x][y] == 2) toy++;
		x = tox, y = toy;
	}
};
vector<vector<pnt > >c;
int n, m, g;
void dfs(pnt a) {
	u[a.x][a.y] = 1;
	pnt s = a;
	a.move();
	while (!u[a.x][a.y]) {
		u[a.x][a.y] = 1;
		a.move();
	}
	if (u[a.x][a.y] == 1) {
		pnt b = a;
		b.move();
		cycle++;
		c.resize(cycle);
		c.back().push_back(a);
		while (b.x != a.x || b.y != a.y) {
			c.back().push_back(b);
			b.move();
		}
	}
	while (u[s.x][s.y] == 1) {
		u[s.x][s.y] = 2;
		s.move();
	}
}
int main() {
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);

	cin >> n >> m >> g;
	dir.resize(m, vector<int>(n));
	rob.resize(m, vector<int>(n)); 
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++){
			char c;
			cin >> c;
			if (c >= 'A' && c <= 'Z')
			rob[j][i] = 1;
			c = toupper(c);
			if (c == 'E') dir[j][i] = 3;
			if (c == 'N') dir[j][i] = 2;
			if (c == 'S') dir[j][i] = 4;
			if (c == 'W') dir[j][i] = 1;
		}
	u.resize(m, vector<int>(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			pnt a = pnt(j, i);
			if (!u[j][i])
				dfs(a);
			u[j][i] = 2;
		}
	int ans = 0;
	for (int i = 0; i < c.size(); i++) {
		ans += c[i].size();
		for (int j = 0; j < c[i].size(); j++)
			if (rob[c[i][j].x][c[i][j].y] == 0) {
				pnt a = c[i][j];
				int fl = 1;
				while (!rob[a.x][a.y])
				{
					a.move1();
					if (a.x < 0 || a.x >= m || a.y < 0 || a.y >= n)
					{
						fl = 0;
						break;
					}
				}
				if (!fl) ans--;
			}
	}
	cout << ans << endl;
}