#include <bits/stdc++.h>

using namespace std;

int n, m, g;
pair<int, int> a[1001][1001];
int used[1001][1001];
int cycles[1001][1001];
vector<pair<int, int>> robots;
int counter = 5;
int cnt = -3;
vector<int> sizes(1000 * 1000);
vector<int> bots(1000 * 1000);

/*
void cycle() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (used[i][j] == counter) {
                cycles[i][j] = counter;
                ++sizes[counter];
            }
        }
    }
}*/

void dfs(int i, int j) {
    used[i][j] = counter;
    cycles[i][j] = counter;
    ++sizes[counter];
    if (used[a[i][j].first][a[i][j].second] != counter) {
        dfs(a[i][j].first, a[i][j].second);
    } else {
      //  cycle();
        return;
    }
}

void dfs0(int i, int j) {
    used[i][j] = cnt;
    if (not used[a[i][j].first][a[i][j].second]) {
        dfs0(a[i][j].first, a[i][j].second);
    } else if (used[a[i][j].first][a[i][j].second] == cnt) {
        ++counter;
        dfs(a[i][j].first, a[i][j].second);
        return;
    }
}



void dfs2(pair<int, int> p) {
    if (cycles[p.first][p.second]) {
        ++bots[ cycles[p.first][p.second] ];
    } else {
        dfs2(a[p.first][p.second]);
    }
}

int main() {
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);


    cin >> n >> m >> g;

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            char c;
            scanf("%c", &c);
            while (c == '\n') {
                scanf("%c", &c);
            }
            if (c != tolower(c)) {
                robots.push_back({i, j});
            }
            c = tolower(c);

            switch (c) {
            case 'n':
                a[i][j] = {i - 1, j};
                break;
            case 's':
                a[i][j] = {i + 1, j};
                break;
            case 'w':
                a[i][j] = {i, j - 1};
                break;
            case 'e':
                a[i][j] = {i, j + 1};
                break;
            }

        }
    }
    memset(cycles, 0, sizeof(cycles));

  /*  for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cout << a[i][j].first << ":" << a[i][j].second << "  ";
        } cout << endl;
    }*/

    memset(used, 0, sizeof(used));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (used[i][j] != 0) continue;
            --cnt;
            dfs0(i, j);
        }
    }

  /*  for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cout << used[i][j] << " ";
        } cout << endl;
    } cout << endl;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cout << cycles[i][j] << " ";
        } cout << endl;
    } cout << endl;*/

    for (auto i : robots) {
        dfs2(i);
    }

    int res = 0;
    for (int i = 5; i <= counter; ++i) {
    //    cout << bots[i] << " " << sizes[i] << endl;
        res += min(bots[i], sizes[i]);
    }
    cout << res << endl;

}
