#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAXN = 1010, INF = 1e9;

#define size(s) (int) (s).size()
#define all(s) (s).begin(), (s).end()
#define rall(s) (s).rbegin(), (s).rend()

int n, m, t, timer = 0, dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}, ans = 0;
int g[MAXN][MAXN], isR[MAXN][MAXN], col[MAXN][MAXN], dist[MAXN][MAXN];
//vector<vector<int> > g, isR, col, tin;
vector<int> cyc;

void init() {
	for (int i = 0; i < MAXN; i++) {
		for (int j = 0; j < MAXN; j++) {
			isR[i][j] = 0;
			col[i][j] = -1;
			dist[i][j] = INF;
		}
	}
}

int getId(char z) {
	if (z == 'N') {
		return 3;
	}
	if (z == 'S') {
		return 1;
	}
	if (z == 'W') {
		return 2;
	}
	if (z == 'E') {
		return 0;
	}
}

int flx = -1, fly;

void findCyc(int x, int y) {
	col[x][y] = size(cyc);
	int nx = x + dx[g[x][y]], ny = y + dy[g[x][y]];
	if (col[nx][ny] != -1) {
		if (col[nx][ny] == col[x][y]) {
			flx = nx;
			fly = ny;
			cyc.push_back(1);
			dist[x][y] = 0;
		} else {
			col[x][y] = col[nx][ny];
			dist[x][y] = dist[nx][ny] + 1;
		}
	} else {
		findCyc(nx, ny);
		col[x][y] = col[nx][ny];
		dist[x][y] = dist[nx][ny] + 1;
		if (flx != -1) {
			dist[x][y] = 0;
			cyc[size(cyc) - 1]++;
			if (flx == x && fly == y) {
				flx = fly = -1;
			}
		}
	}
}

int main() {
	init();
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	cin >> n >> m >> t;
	/*if (n == 3 && m == 4 && t == 1) {
		cout << "4\n2 3 2\n3 4 1\n2 1 2\n";
		return 0;
	}
	if (n == 4 && m == 4 && t == 1) {
		cout << "5\n1 4 9\n2 1 4\n4 3 3\n4 1 2\n4 4 7\n";
		return 0;
	}*/
	/*isR.resize(n, vector<int> (m, 0));
	tin.resize(n, vector<int> (m));
	g.resize(n, vector<int> (m));
	col.resize(n, vector<int> (m, -1));*/
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char z;
			cin >> z;
			if ('A' <= z && z <= 'Z') {
				isR[i][j] = 1;
			}
			z = toupper(z);
			g[i][j] = getId(z);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (col[i][j] == -1) {
				findCyc(i, j);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (isR[i][j] == 1 && !(col[i][j] >= 0 && col[i][j] < size(cyc))) {
				cout << "QQQQQ\n";
				return 0;
			}
			if (isR[i][j] == 1 && cyc[col[i][j]] > 0) {
				cyc[col[i][j]]--;
				ans++;
			}
		}
	}
	cout << ans << '\n';
    return 0;
}

