#include <bits/stdc++.h>

#define vec vector
#define forn(i, n) for (int i = 0; i < n; i++)
#define mp make_pair
#define YY second
#define XX first
#define vec vector
#define str string
#define pb push_back
#define ll long long
#define all(a) a.begin(), a.end()

using namespace std;

const bool is_testing = false;

int n, m, g;
char a[507][507];
bool was[507][507];
bool is[507][507];
int cyc[507][507];
int op[100008];
int sz[100008];
int kkk = 0;

pair<int, int> pred[100007];

void caps(int x, int y)
{
    if (a[x][y] == 's')
        a[x][y] = 'S';
    if (a[x][y] == 'n')
        a[x][y] = 'N';
    if (a[x][y] == 'w')
        a[x][y] = 'W';
    if (a[x][y] == 'e')
        a[x][y] = 'E';
}

bool cap(char c)
{
    return (c == 'N' || c == 'W' || c == 'E' || c == 'S');
}

void dfs(int x, int y, int k)
{
    if (was[x][y])
    {
        bool f = false;
        forn(i, k)
            if (pred[i] == mp(x, y))
                f = true;
        if (f)
        {
            pair<int, int> start = mp(x, y);
            kkk++;
            is[x][y] = true;
            cyc[x][y] = kkk;
            sz[kkk]++;
            if (cap(a[x][y]))
                op[kkk]++;
            reverse(pred, pred + k);
            forn(i, k)
                if (pred[i] != start)
                {
                    is[pred[i].XX][pred[i].YY] = true;
                    cyc[pred[i].XX][pred[i].YY] = kkk;
                    sz[kkk]++;
                    if (cap(a[pred[i].XX][pred[i].YY]))
                        op[kkk]++;
                }
                else
                {
                    break;
                }
        }
        else
        {
            int num = cyc[x][y];
            if (op[num] < sz[num])
                op[num]++;
        }
    }
    else
    {
        was[x][y] = true;
        pred[k] = mp(x, y);
        if (a[x][y] == 'S' || a[x][y] == 's')
            dfs(x + 1, y, k + 1);
        if (a[x][y] == 'N' || a[x][y] == 'n')
            dfs(x - 1, y, k + 1);
        if (a[x][y] == 'W' || a[x][y] == 'w')
            dfs(x, y - 1, k + 1);
        if (a[x][y] == 'E' || a[x][y] == 'e')
            dfs(x, y + 1, k + 1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    if (is_testing)
    {
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    }
    cin >> n >> m >> g;
    forn(i, n)
        forn(j, m)
            cin >> a[i][j];
    forn(i, n)
        forn(j, m)
        if (!was[i][j])
        {
            dfs(i, j, 0);
        }
    int ans = 0;
    /*forn(i, n)
    {
        forn(j, m)
            cout << cyc[i][j] << ' ';
        cout << endl;
    }*/
    set<int> d;
    forn(i, n)
        forn(j, m)
            if (is[i][j])
            {
                int num = cyc[i][j];
                if (!d.count(num))
                {
                    d.insert(num);
                    ans += op[num];
                }
            }
    cout << ans;
}
