#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#pragma comment(linker, "/STACK:104857600")
using namespace std;
vector<vector<bool> > vis;
vector <vector<int> > in_cycle;
vector<int> cycles;
vector<int> caught;
vector<vector<char> > a;
int lcycle = -1;
int n, m;
int ans = 0;
int dfs(int x, int y, int length)
{
	int i = x, j = y;
	if (vis[x][y] == 1 && in_cycle[x][y] == -1)
	{
		lcycle++;
		cycles.push_back(1);
		caught.push_back(length);
		in_cycle[x][y] = lcycle;
		if (a[x][y] == 'N' || a[x][y] == 'n')
		{
			i--;
		}
		else if (a[x][y] == 'S' || a[x][y] == 's')
		{
			i++;
		}
		else if (a[x][y] == 'E' || a[x][y] == 'e')
		{
			j++;
		}
		else if (a[x][y] == 'W' || a[x][y] == 'w')
		{
			j--;
		}
		while (i != x || j != y)
		{
			cycles[lcycle]++;
			in_cycle[i][j] = lcycle;
			if (a[i][j] == 'N' || a[i][j] == 'n')
			{
				i--;
			}
			else if (a[i][j] == 'S' || a[i][j] == 's')
			{
				i++;
			}
			else if (a[i][j] == 'E' || a[i][j] == 'e')
			{
				j++;
			}
			else if (a[i][j] == 'W' || a[i][j] == 'w')
			{
				j--;
			}
		}
		return in_cycle[x][y];
	}
	else if (in_cycle[x][y] != -1) 
	{
		caught[in_cycle[x][y]] += length;
		return in_cycle[x][y];
	}
	else if (vis[x][y] == 0) 
	{
		if (a[x][y] == 'N' || a[x][y] == 'W' || a[x][y] == 'S' || a[x][y] == 'E') length++;
		if (a[i][j] == 'N' || a[i][j] == 'n')
		{
			i--;
		}
		else if (a[i][j] == 'S' || a[i][j] == 's')
		{
			i++;
		}
		else if (a[i][j] == 'E' || a[i][j] == 'e')
		{
			j++;
		}
		else if (a[i][j] == 'W' || a[i][j] == 'w')
		{
			j--;
		}
		vis[x][y] = 1;
		in_cycle[x][y] = dfs(i, j, length);
		return(in_cycle[x][y]);
	}
}
int main()
{
	ifstream in;
	ofstream out;
	in.open("robots.in");
	out.open("robots.out");
	int i, j, g;
	in >> n >> m >> g;
	a.assign(n, vector<char>(m));
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			in >> a[i][j];
		}
	}
	vis.assign(n, vector<bool>(m, 0));
	in_cycle.assign(n, vector<int>(m, -1));
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			if (vis[i][j] == 0) dfs(i, j, 0);
		}
	}
	for (i = 0; i <= lcycle; i++)
	{
		ans += min(caught[i], cycles[i]);
	}
	out << ans;
	in.close();
	out.close();
}