#include <bits/stdc++.h>

using namespace std;

const int MX_SZ = 1042;
char a[MX_SZ][MX_SZ];
int n, m;
bool used[MX_SZ][MX_SZ];
bool cycle;
pair<int, int> v0;
/*
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
*/

inline pair<int, int> get_w(char c)
{
    if (c == 'w' or c == 'W')
    {
        return {0, -1};
    }
    if (c == 'e' or c == 'E')
    {
        return {0, 1};
    }
    if (c == 'n' or c == 'N')
    {
        return {-1, 0};
    }
    if (c == 's' or c == 'S')
    {
        return {1, 0};
    }
}

void dfs(int x, int y)
{
    used[x][y] = true;
    pair<int, int> mod = get_w(a[x][y]);
    int nx = x + mod.first, ny = y + mod.second;
    if (nx == v0.first and ny == v0.second)
    {
        cycle = true;
        return;
    }
    if (!used[nx][ny])
    {
        dfs(nx, ny);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    int g;
    cin >> n >> m >> g;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            v0 = {i, j};
            cycle = false;
            memset(used, false, sizeof(used));
            dfs(i, j);
            ans += cycle;
        }
    }
    cout << ans;
}
