#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
#define ll long long
using namespace std;

const int MAXN = 1e3 + 111;

int n, m, g;

string s[MAXN];

int len[MAXN * MAXN], cnt[MAXN * MAXN];

int ans = 0;

int cur = 0;

int cycle[MAXN][MAXN];

vector <pair <int, int> > path;

map <char, pair <int, int> > mp;

bool was[MAXN][MAXN];

void init()
{
	memset(cycle, -1, sizeof cycle);
	mp['S'] = mp['s'] = make_pair(1, 0);
	mp['N'] = mp['n'] = make_pair(-1, 0);
	mp['W'] = mp['w'] = make_pair(0, -1);
	mp['E'] = mp['e'] = make_pair(0, 1);
}

bool have(int x, int y)
{
	return s[x][y] < 'a';
}

void cover(int x, int y)
{
	int id = path.size() - 1;
	int ln = 0;
	while (id >= 0)
	{
		ln++;
		cycle[path[id].first][path[id].second] = cur;
		if (path[id] == make_pair(x, y))
			break;
		id--;
	}
	len[cur] = ln;
	cnt[cur] = 1;
	cur++;
}

void go(int x, int y)
{
	memset(was, 0, sizeof was);
	path.clear();
	while (true)
	{
		was[x][y] = true;
		path.push_back(make_pair(x, y));
		if (cycle[x][y] != -1)
		{
			if (cnt[cycle[x][y]] < len[cycle[x][y]])
			{
				cnt[cycle[x][y]]++;
				ans++;
			}
			break;
		}
		int nx = x + mp[s[x][y]].first;
		int ny = y + mp[s[x][y]].second;
		if (was[nx][ny])
		{
			cover(nx, ny);
			ans++;
			break;
		}
		x = nx;
		y = ny;
	}
}

int main()
{
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	scanf("%d %d %d", &n, &m, &g);
	for (int i = 0; i < n; i++)
		cin >> s[i];
	init();
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (have(i, j))
				go(i, j);
		}
	}
	cout << ans;
	return 0;
}