#include <iostream>
#include <vector>
#include <cstdio>
#include <cassert>
#include <set>
#include <map>

using namespace std;

struct Cell {
    int x, y;
    bool valid() const {
        return x >= 0 && y >= 0;
    }
    bool operator <(const Cell &c) const {
        return x < c.x || (x == c.x && y < c.y);
    }
};

int dx(char dir) {
    if (dir == 'e' || dir == 'E') {
        return 1;
    }
    if (dir == 'w' || dir == 'W') {
        return -1;
    }
    return 0;
}

int dy(char dir) {
    if (dir == 's' || dir == 'S') {
        return 1;
    }
    if (dir == 'n' || dir == 'N') {
        return -1;
    }
    return 0;
}

bool robot(char dir) {
    return dir == 'N' || dir == 'E' || dir == 'W' || dir == 'S';
}

Cell find_cycle(vector<vector<char>> &field, int x, int y, vector<vector<bool>> &used, vector<vector<Cell>> &cycle_element) {
    int nx = x + dx(field[x][y]);
    int ny = y + dy(field[x][y]);
    used[x][y] = true;
    if (used[nx][ny]) {
        if (cycle_element[nx][ny].valid()) {
            cycle_element[x][y] = cycle_element[nx][ny];
        } else {
            cycle_element[x][y] = Cell{nx, ny};
        }
    } else {
        cycle_element[x][y] = find_cycle(field, nx, ny, used, cycle_element);
    }
    return cycle_element[x][y];
}

void dfs(vector<vector<char>> &field, int x, int y, vector<vector<bool>> &used) {
    int nx = x + dx(field[x][y]);
    int ny = y + dy(field[x][y]);
    used[x][y] = true;
    if (!used[nx][ny]) {
        dfs(field, nx, ny, used);
    }
}

struct Cycle {
    int avail, size;
};

int main() {
#ifndef LOCAL
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
#endif
    int n, m, g;
    cin >> n >> m >> g;
    assert(g == 0);
    vector<vector<char>> field(m, vector<char>(n));
    for (int y = 0; y < n; y++) {
        for (int x = 0; x < m; x++) {
            cin >> field[x][y];
        }
    }
    set<Cell> cycles;
    vector<vector<bool>> used(m, vector<bool>(n, false));
    vector<vector<bool>> in_cycle(m, vector<bool>(n, false));
    vector<vector<Cell>> cycle_element(m, vector<Cell>(n, Cell{-1, -1}));
    for (int x = 0; x < m; x++) {
        for (int y = 0; y < n; y++) {
            if (!used[x][y]) {
                cycles.insert(find_cycle(field, x, y, used, cycle_element));
            }
        }
    }

    map<Cell, Cycle> dp;
    for (auto c : cycles) {
        dfs(field, c.x, c.y, in_cycle);
        dp[c] = Cycle{0, 0};
    }
    
    for (int x = 0; x < m; x++) {
        for (int y = 0; y < n; y++) {
            Cell c = cycle_element[x][y];
            if (robot(field[x][y])) {
                dp[c].avail++;
            }
            if (in_cycle[x][y]) {
                dp[c].size++;
            }
        }
    }

    int ans = 0;
    for (auto c : dp) {
        ans += min(c.second.size, c.second.avail);
    }

    cout << ans << endl;

    return 0;
}
