#include <iostream>
#include <vector>

using namespace std;

vector < vector < int > > b, col;
vector < vector < pair < int, int > > > a;

pair <int, int> dfs(int x, int y) {
	if (col[x][y] == 2)
		return{ -1, -1 };
	if (col[x][y] == 1)
		return{ x, y };
	col[x][y] = 1;
	pair <int, int> res = dfs(x + a[x][y].first, y + a[x][y].second);
	if (res != make_pair(-1, -1))
		b[x][y] = 1;
	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);
	int n, m, g;
	cin >> n >> m >> g;
	a.resize(n, vector<pair<int, int>>(m));
	b.resize(n, vector<int>(m));
	col.resize(n, vector<int>(m, 0));
	for (int i = 0; i < n; i++) {
		for (int 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 };
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			dfs(i, j);
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			ans += b[i][j];
		}
	}
	cout << ans;
	return 0;
}