#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;
const int MAXN = 1001;
bool used[MAXN][MAXN];
char g[MAXN][MAXN];
bool est[MAXN][MAXN];
int n, m;
vector <pair <int, int> > ans;
vector <pair <int, int> > tp;

void dfs(int x, int y){
    used[x][y] = true;
    ans.push_back(make_pair(x, y));
    if ((y < m - 1) && (g[x][y + 1] == 'W') && (!used[x][y + 1])){
        dfs(x, y + 1);
    }
    if ((y > 0) && (g[x][y - 1] == 'E') && (used[x][y - 1] == false)){
        dfs(x, y - 1);
    }
    if ((x < n - 1) && (g[x + 1][y] == 'N') && (used[x + 1][y] == false)){
        dfs(x + 1, y);
    }
    if ((x > 0) && (g[x - 1][y] == 'S') && (used[x - 1][y] == false)){
        dfs(x - 1, y);
    }
}
void top(int x, int y){
    used[x][y] = true;
    if ((g[x][y] == 'S') && (!used[x + 1][y])){
        top(x + 1, y);
    }
    else if ((g[x][y] == 'N') && (!used[x - 1][y])){
        top(x - 1, y);
    }
    else if ((g[x][y] == 'W') && (!used[x][y - 1])){
        top(x, y - 1);
    }
    else if ((g[x][y] == 'E') && (!used[x][y + 1])){
        top(x, y + 1);
    }
    tp.push_back(make_pair(x, y));
}

int main(){
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    int v;
    cin >> n >> m >> v;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> g[i][j];
            if (g[i][j] == 'w'){
                g[i][j] = 'W';
                est[i][j] = true;
            }
            if (g[i][j] == 'e'){
                g[i][j] = 'E';
                est[i][j] = true;
            }
            if (g[i][j] == 's'){
                g[i][j] = 'S';
                est[i][j] = true;
            }
            if (g[i][j] == 'n'){
                g[i][j] = 'N';
                est[i][j] = true;
            }
            used[i][j] = false;
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (!used[i][j]){
                top(i, j);
            }
        }
    }
    //for (int i = 0; i < tp.size(); i++){
    //    cout << tp[i].first << ' ' << tp[i].second << endl;
    //}
    //cout << endl;
    //cout << endl;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            used[i][j] = false;
        }
    }
    int sm = 0;
    for (int i = tp.size() - 1; i >= 0; i--){
        pair <int, int> elem = tp[i];
        ans.resize(0);
        if (!used[elem.first][elem.second]){
            dfs(elem.first, elem.second);
        }
        if (ans.size() > 1){
            for (int i = 0; i < ans.size(); i++){
                if (!est[ans[i].first][ans[i].second]){
                    sm += 1;
                }
            }
        }
        //for (int i = 0; i < ans.size(); i++){
        //    cout << ans[i].first << ' ' << ans[i].second << endl;
        //}
        //cout << endl;
    }
    cout << sm;
}
