#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mk make_pair
#define ppb pop_back
#define pb push_back
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
#define forq(i, q, n) for(int i = 1; i < n; ++i)
#define all(a) a.begin(), a.end()
#define x first
#define y second

const int mod = 1e9 + 7;
const ll inf = 1e15 + 7;
const double eps = 1e-6;
const int MAXN = 1e3 + 7;

char a[MAXN][MAXN];
pii used[MAXN][MAXN];
vector<pii> c;
vector<vector<pii> > v;
int n, m, g;

int dfs(int x, int y)
{
	/*forn(i, n)
	{
		forn(j, m)
			cout << used[i][j].y << " " << used[i][j].y << " # ";
		cout << "\n";
	}
	cout << "\n";*/

	if (used[x][y].x == 1 || used[x][y].x == -1)
	{
		if (used[x][y].x == 1)
			return used[x][y].y + 1;
		else
			return 0;
	}
	if (used[x][y].x == 3)
	{
		used[x][y].x = -1;
		return 0;
	}
	if (used[x][y].x == 2)
	{
		used[x][y].x = 3;
		return -1;
	}
	if (used[x][y].x == 0)
		used[x][y].x = 2;
	int f = -17;
	if (a[x][y] == 'n' || a[x][y] == 'N')
		f = dfs(x - 1, y);
	else
		if (a[x][y] == 's' || a[x][y] == 'S')
			f = dfs(x + 1, y);
		else
			if (a[x][y] == 'w' || a[x][y] == 'W')
				f = dfs(x, y - 1);
			else
				f = dfs(x, y + 1);
	
	/*forn(i, n)
	{
		forn(j, m)
			cout << used[i][j].y << " " << used[i][j].y << " # " ;
		cout << "\n";
	}
	cout << "\n";*/
	if (f == -1)
	{
		if (used[x][y].x != 3)
		{
			c.pb(mk(x, y));
			used[x][y].x = -1;
			used[x][y].y = 0;
			return -1;
		}
		else
		{
			c.pb(mk(x, y));
			used[x][y].x = -1;
			return 0;
		}
	}
	else
	{
		used[x][y].y = f;
		used[x][y].x = 1;
		return f + 1;
	}
		
}


void findc(int n, int m)
{
	forn(i, n)
		forn(j, m)
		{
			c.clear();
			dfs(i, j);
			if (c.size())
				v.pb(c);
		}
			
}

int 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;
	string st;
	forn(i, n)
	{
		cin >> st;
		forn(j, m)
			a[i][j] = st[j];
	}
	findc(n, m);
	ll ans = 0;
	forn(i, v.size())
	{
		forn(j, v[i].size())
			if (a[v[i][j].x][v[i][j].y] == 'W' || 
				a[v[i][j].x][v[i][j].y] == 'N' || 
				a[v[i][j].x][v[i][j].y] == 'E' || 
				a[v[i][j].x][v[i][j].y] == 'S')
				ans++;
	}
	cout << ans;

	return 0;
}