#define consfl 0
#define fname "robots"

#include <iostream>
#include <cstdio>
#include <cstdlib>

#include <algorithm>
#include <cmath>

#include <vector>

#define forn(i, n) for (int i = 0; i < n; i ++)
#define fornn(i, n, m) for (int i = n; i < m; i ++)
#define mk make_pair
#define outb pop_back
#define inb push_back

using namespace std;

const int dd = 1e5;

char f[2000][2000];
int c[2000][2000];
bool used[2000][2000];

vector<int> cic;
vector<pair<int, int> > way;

void go(int x, int y) {
	used[x][y] = 1;
	way.inb(mk(x, y));
	int xn = x;
	int yn = y;
	if (f[x][y] == 'S' || f[x][y] == 's')
		xn++;
	if (f[x][y] == 'W' || f[x][y] == 'w')
		yn--;
	if (f[x][y] == 'N' || f[x][y] == 'n')
		xn--;
	if (f[x][y] == 'E' || f[x][y] == 'e')
		yn++;
	if (!used[xn][yn]) {
		go(xn, yn);
		c[x][y] = c[xn][yn];
	}
	else
		if (!c[xn][yn]) {
			int sz = 1;
			while (way.back() != mk(xn, yn))
				way.outb(), sz++;
			cic.inb(sz);
			c[x][y] = cic.size();
		}
		else
			c[x][y] = c[xn][yn];
}

int main(){
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	if (!consfl) {
		freopen(fname".in", "r", stdin);
		freopen(fname".out", "w", stdout);
	}
#endif
	int n, m, g;
	cin >> n >> m >> g;

	forn(i, n)
		forn(j, m)
			cin >> f[i][j];

	forn(i, n)
		forn(j, m)
			if ('A' <= f[i][j] && f[i][j] <= 'Z')
				go(i, j);
	int ans = 0;
	forn(i, n)
		forn(j, m)
			if ('A' <= f[i][j] && f[i][j] <= 'Z') {
				if (cic[c[i][j] - 1])
					ans++, cic[c[i][j] - 1] --;
			}
	cout << ans;
	return 0;
}