#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stdio.h>
#include <list>
#include <algorithm>
#pragma warning(disable: 4996)
typedef long long ll;
typedef long double ld;
using namespace std;

const ll SZ = 1e3 + 10;
const ll INF = 1e9;

string st[SZ];
bool v[SZ][SZ];
pair<int, int> s[SZ][SZ];
vector<int> cycsize = { 0 };
vector<pair<int, int>> stack;

void dfs(int x, int y) {
	if (v[x][y]) {
		if (!s[x][y].first) {
			cycsize.push_back(0);
			while (true) {
				cycsize.back()++;
				s[stack.back().first][stack.back().second] = { cycsize.size() - 1, 0 };
				if (stack.back() == make_pair(x, y))
					break;
				stack.pop_back();
			}
			int c = 0;
			while (stack.size()) {
				s[stack.back().first][stack.back().second] = { cycsize.size() - 1, ++c };
				stack.pop_back();
			}
		} else {
			int c = s[x][y].second;
			while (stack.size()) {
				s[stack.back().first][stack.back().second] = { s[x][y].first, ++c };
				stack.pop_back();
			}
		}
		return;
	}
	stack.push_back({ x, y });
	v[x][y] = true;
	if (st[x][y] == 'N' || st[x][y] == 'n')
		dfs(x - 1, y);
	else if (st[x][y] == 'S' || st[x][y] == 's')
		dfs(x + 1, y);
	else if (st[x][y] == 'W' || st[x][y] == 'w')
		dfs(x, y - 1);
	else
		dfs(x, y + 1);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
#endif

	int n, m, g;
	cin >> n >> m >> g;
	for (int i = 0; i < n; i++)
		cin >> st[i];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (!v[i][j])
				dfs(i, j);

	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (cycsize[s[i][j].first] && st[i][j] >= 'A' && st[i][j] <= 'Z')
				ans++, cycsize[s[i][j].first]--;

	cout << ans;

	return 0;
}