#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <ctime>
#include <set>
#include <map>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <memory.h>

using namespace std;

//#define int long long
#define sz(a) (int)(a.size())

int n, m;
const int MAXN = 1111;
char c[MAXN][MAXN];
pair<int, int> t[MAXN][MAXN];
int g;
int used[MAXN][MAXN];
int comp[MAXN][MAXN];
int color[MAXN][MAXN];
vector<pair<int, int>> path;
int cur = 1;
int cnt[MAXN * MAXN];
int v[MAXN][MAXN];

void dfs(int x, int y, int k = 1)
{
	used[x][y] = k;
	path.push_back({ x, y });
	if (c[x][y] == 's' || c[x][y] == 'S')
	{
		if (!used[x + 1][y])
			dfs(x + 1, y, k + 1);
		else
			path.push_back({ 0, used[x + 1][y] - 1 });
	}
	if (c[x][y] == 'n' || c[x][y] == 'N')
	{
		if (!used[x - 1][y])
			dfs(x - 1, y, k + 1);
		else
			path.push_back({ 0, used[x - 1][y] - 1 });
	}
	if (c[x][y] == 'w' || c[x][y] == 'W')
	{
		if (!used[x][y - 1])
			dfs(x, y - 1, k + 1);
		else
			path.push_back({ 0, used[x][y - 1] - 1 });
	}
	if (c[x][y] == 'e' || c[x][y] == 'E')
	{
		if (!used[x][y + 1], k + 1)
			dfs(x, y + 1, k + 1);
		else
			path.push_back({ 0, used[x][y + 1] - 1 });
	}
}

void color_dfs(int x, int y)
{
	color[x][y] = cur;
	if (c[x][y] == 's' || c[x][y] == 'S')
	{
		if (color[x + 1][y] == 0)
			color_dfs(x + 1, y);
	}
	if (c[x][y] == 'n' || c[x][y] == 'N')
	{

		if (color[x - 1][y] == 0)
			color_dfs(x - 1, y);
	}
	if (c[x][y] == 'w' || c[x][y] == 'W')
	{

		if (color[x][y - 1] == 0)
			color_dfs(x, y - 1);
	}
	if (c[x][y] == 'e' || c[x][y] == 'E')
	{
		if (color[x][y + 1] == 0)
			color_dfs(x, y + 1);
	}
}

signed main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	cin >> n >> m >> g;
	assert(g == 0);
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			cin >> c[i][j];
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			path.clear();
			for (int k = 1; k <= n; ++k)
			{
				memset(used[k], 0, sizeof(used[k][0]) * (m + 1));
			}
			dfs(i, j);
			t[i][j] = path[path.back().second];
			v[i][j] = sz(path) - path.back().second - 1;
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if (color[t[i][j].first][t[i][j].second] == 0)
			{
				color_dfs(t[i][j].first, t[i][j].second);
				comp[i][j] = color[t[i][j].first][t[i][j].second];
				cnt[cur] = v[i][j];
				++cur;
			}
			else
			{
				comp[i][j] = color[t[i][j].first][t[i][j].second];
				cnt[cur] = v[i][j];
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if (c[i][j] == 'S' || c[i][j] == 'W' || c[i][j] == 'N' || c[i][j] == 'E')
			{
				if (cnt[comp[i][j]] > 0)
				{
					--cnt[comp[i][j]];
					++ans;
				}
			}
		}
	}
	cout << ans;
	return 0;
}