#include <iostream>
#include <vector>

using namespace std;

vector < vector < long long > > b, col, t, comp;
vector < vector < pair < long long, long long > > > a;
vector <long long> sz;
long long n, m, g;

pair <long long, long long> dfs(long long x, long long y) {
	if (x >= n || x < 0 || y < 0 || y >= m) {
		return{ -2, -2 };
	}
	if (col[x][y] == 2)
		return{ -1, -1 };
	if (col[x][y] == 1) {
		sz.push_back(0);
		comp[x][y] = sz.size() - 1;
		return{ x, y };
	}
	col[x][y] = 1;
	pair <long long, long long> res = dfs(x + a[x][y].first, y + a[x][y].second);
	if (res.first >= 0) {
		if (t[x][y])
			b[x][y] = 1;
		else
			sz[sz.size() - 1]++;
		comp[x][y] = sz.size() - 1;
	}
	else if (res != make_pair((long long)-2, (long long)-2)) {
		long long _x = x + a[x][y].first;
		long long _y = y + a[x][y].second;
		comp[x][y] = comp[_x][_y];
		if (t[x][y] && sz[comp[x][y]]) {
			b[x][y] = 1;
			sz[comp[x][y]]--;
		}
	}
	else
		return{ -2, -2 };
	col[x][y] = 2;
	if (res == make_pair(x, y))
		return{ -1, -1 };
	else
		return res;
}

int main() {
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	cin >> n >> m >> g;
	a.resize(n, vector<pair<long long, long long>>(m));
	b.resize(n, vector<long long>(m, 0));
	t.resize(n, vector<long long>(m, 0));
	col.resize(n, vector<long long>(m, 0));
	comp.resize(n, vector<long long>(m));
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j < m; j++) {
			char c;
			cin >> c;
			if (c == 'N' || c == 'n')
				a[i][j] = { -1, 0 };
			if (c == 'W' || c == 'w')
				a[i][j] = { 0, -1 };
			if (c == 'E' || c == 'e')
				a[i][j] = { 0, 1 };
			if (c == 'S' || c == 's')
				a[i][j] = { 1, 0 };
			if (c == 'S' || c == 'N' || c == 'E' || c == 'W')
				t[i][j] = 1;
		}
	}
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j < m; j++) {
			dfs(i, j);
		}
	}
	long long ans = 0;
	for (long long i = 0; i < n; i++) {
		for (long long j = 0; j < m; j++) {
			ans += b[i][j];
		}
	}
	cout << ans;
	return 0;
}