#include <iostream>
#include <sstream>
#include <cstdio>
#include <set>
#include <algorithm>
#include <cmath>
#include <vector>


using namespace std;

int n, m, g;
string s[1001];
bool used[1001][1001];
int incycle[1001][1001];
vector<pair<int, int> > cycle[1000011];
vector<pair<int, int> > topsort;
int dist[1001][1001];


void dfs(int i, int j) {
    //cout << "opa" << ' ' << i << ' ' << j << endl;
    if (i >= 1 && (s[i - 1][j] == 'S' || s[i - 1][j] == 's') && !incycle[i - 1][j]) {
        dist[i - 1][j] = dist[i][j] + 1;
        dfs(i - 1, j);
    }
    if (i < n - 1 && (s[i + 1][j] == 'N' || s[i + 1][j] == 'n') && !incycle[i + 1][j]) {
        dist[i + 1][j] = dist[i][j] + 1;
        dfs(i + 1, j);
    }
    if (j >= 1 && (s[i][j - 1] == 'E' || s[i][j - 1] == 'e') && !incycle[i][j - 1]) {
        dist[i][j - 1] = dist[i][j] + 1;
        dfs(i, j - 1);
    }
    if (j < m - 1 && (s[i][j + 1] == 'W' || s[i][j + 1] == 'w') && !incycle[i][j + 1]) {
        dist[i][j + 1] = dist[i][j] + 1;
        dfs(i, j + 1);
    }
    if (s[i][j] >= 'A' && s[i][j] <= 'Z') {
        topsort.push_back(make_pair(i, j));
    }
}


int main() {
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    cin >> n >> m >> g;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int cnt = 0;
    for (int i1 = 0; i1 < n; i1++) {
        for (int j1 = 0; j1 < m; j1++) {
            //cout << i1 << ' ' << j1 << endl;
            //cout << s[i1][j1] << endl;
            if (!incycle[i1][j1]) {
                if (s[i1][j1] == 'S' || s[i1][j1] == 's') {
                    if (s[i1 + 1][j1] == 'N' || s[i1 + 1][j1] == 'n') {
                        cnt++;
                        incycle[i1][j1] = cnt;
                        used[i1][j1] = 1;
                        used[i1 + 1][j1] = 1;
                        incycle[i1 + 1][j1] = cnt;
                        cycle[cnt].push_back(make_pair(i1, j1));
                        cycle[cnt].push_back(make_pair(i1 + 1, j1));
                        continue;
                    }
                }
                if (s[i1][j1] == 'N' || s[i1][j1] == 'n') {
                    if (s[i1 - 1][j1] == 'S' || s[i1 - 1][j1] == 's') {
                        cnt++;
                        incycle[i1][j1] = cnt;
                        used[i1][j1] = 1;
                        used[i1 - 1][j1] = 1;
                        incycle[i1 - 1][j1] = cnt;
                        cycle[cnt].push_back(make_pair(i1, j1));
                        cycle[cnt].push_back(make_pair(i1 - 1, j1));
                        continue;
                    }
                }
                if (s[i1][j1] == 'E' || s[i1][j1] == 'e') {
                    if (s[i1][j1 + 1] == 'W' || s[i1][j1 + 1] == 'w') {
                        cnt++;
                        incycle[i1][j1] = cnt;
                        used[i1][j1] = 1;
                        used[i1][j1 + 1] = 1;
                        incycle[i1][j1 + 1] = cnt;
                        cycle[cnt].push_back(make_pair(i1, j1));
                        cycle[cnt].push_back(make_pair(i1, j1 + 1));
                        continue;
                    }
                }
                if (s[i1][j1] == 'W' || s[i1][j1] == 'w') {
                    if (s[i1][j1 - 1] == 'E' || s[i1][j1 - 1] == 'e') {
                        cnt++;
                        incycle[i1][j1] = cnt;
                        used[i1][j1] = 1;
                        used[i1][j1 - 1] = 1;
                        incycle[i1][j1 - 1] = cnt;
                        cycle[cnt].push_back(make_pair(i1, j1));
                        cycle[cnt].push_back(make_pair(i1, j1 - 1));
                        continue;
                    }
                }
            }
            if (!used[i1][j1] && !incycle[i1][j1]) {
                int i = i1;
                int j = j1;
                int cntc = 0;
                while (!used[i][j] && !incycle[i][j]) {
                    used[i][j] = 1;
                    cntc++;
                    if (s[i][j] == 'S' || s[i][j] == 's') {
                        i++;
                        continue;
                    }
                    if (s[i][j] == 'N' || s[i][j] == 'n') {
                        i--;
                        continue;
                    }
                    if (s[i][j] == 'E' || s[i][j] == 'e') {
                        j++;
                        continue;
                    }
                    if (s[i][j] == 'W' || s[i][j] == 'w') {
                        j--;
                        continue;
                    }
                }
                //cout << cntc << endl;
               // cout << i << ' ' << j << endl;
                if (i == i1 && j == j1) {
                    if (cntc < 2) {
                        continue;
                    }
                    i = i1;
                    j = j1;
                    cnt++;
                    while (!incycle[i][j]) {
                        incycle[i][j] = cnt;
                        used[i][j] = 1;
                        cycle[cnt].push_back(make_pair(i, j));
                        if (s[i][j] == 'S' || s[i][j] == 's') {
                            i++;
                            continue;
                        }
                        if (s[i][j] == 'N' || s[i][j] == 'n') {
                            i--;
                            continue;
                        }
                        if (s[i][j] == 'E' || s[i][j] == 'e') {
                            j++;
                            continue;
                        }
                        if (s[i][j] == 'W' || s[i][j] == 'w') {
                            j--;
                            continue;
                        }
                    }
                    if ((int)cycle[cnt].size() == 1) {
                        incycle[cycle[cnt][0].first][cycle[cnt][0].second] = 0;
                        used[cycle[cnt][0].first][cycle[cnt][0].second] = 0;
                        cycle[cnt].pop_back();
                        cnt--;
                    }
                    if ((int)cycle[cnt].size() == 2) {
                        incycle[cycle[cnt][1].first][cycle[cnt][1].second] = 0;
                        used[cycle[cnt][1].first][cycle[cnt][1].second] = 0;
                        cycle[cnt].pop_back();
                        incycle[cycle[cnt][0].first][cycle[cnt][0].second] = 0;
                        used[cycle[cnt][0].first][cycle[cnt][0].second] = 0;
                        cycle[cnt].pop_back();
                        cnt--;
                    }
                    continue;
                }
                if (!incycle[i][j]) {
                    if (cntc < 2) {
                        continue;
                    }
                    cnt++;
                    while (!incycle[i][j]) {
                        incycle[i][j] = cnt;
                        used[i][j] = 1;
                        cycle[cnt].push_back(make_pair(i, j));
                        if (s[i][j] == 'S' || s[i][j] == 's') {
                            i++;
                            continue;
                        }
                        if (s[i][j] == 'N' || s[i][j] == 'n') {
                            i--;
                            continue;
                        }
                        if (s[i][j] == 'E' || s[i][j] == 'e') {
                            j++;
                            continue;
                        }
                        if (s[i][j] == 'W' || s[i][j] == 'w') {
                            j--;
                            continue;
                        }
                    }
                    if ((int)cycle[cnt].size() == 1) {
                        incycle[cycle[cnt][0].first][cycle[cnt][0].second] = 0;
                        used[cycle[cnt][0].first][cycle[cnt][0].second] = 0;
                        cycle[cnt].pop_back();
                        cnt--;
                    }
                    if ((int)cycle[cnt].size() == 2) {
                        incycle[cycle[cnt][1].first][cycle[cnt][1].second] = 0;
                        used[cycle[cnt][1].first][cycle[cnt][1].second] = 0;
                        cycle[cnt].pop_back();
                        incycle[cycle[cnt][0].first][cycle[cnt][0].second] = 0;
                        used[cycle[cnt][0].first][cycle[cnt][0].second] = 0;
                        cycle[cnt].pop_back();
                        cnt--;
                    }
                    continue;
                }
            }
        }
    }
   // cout << cnt << endl;
    int ans = 0;
    vector<pair<pair<int, int>, int> > v;
    for (int k = 1; k <= cnt; k++) {
        int p = (int)cycle[k].size();
      //  cout << k << endl;
        for (int i = 0; i < (int)cycle[k].size(); i++) {
            int i1 = cycle[k][i].first;
            int j1 = cycle[k][i].second;
            //cout << i1 << ' ' << j1 << endl;
            if (s[i1][j1] >= 'A' && s[i1][j1] <= 'Z') {
                ans++;
                p--;
                v.push_back(make_pair(make_pair(i1, j1), 0));
            }
        }
        for (int i = 0; i < (int)cycle[k].size(); i++) {
            int i1 = cycle[k][i].first;
            int j1 = cycle[k][i].second;
            topsort.clear();
            //cout << k << ' ' << i <<  endl;
            dfs(i1, j1);
            if (!topsort.empty()) {
               // cout << (int)topsort.size() << ' ' << k << endl;
                reverse(topsort.begin(), topsort.end());
                for (int j = 0; j < (int)topsort.size() && p != 0; j++) {
                    i1 = topsort[j].first;
                    j1 = topsort[j].second;
                    if (!incycle[i1][j1] && s[i1][j1] >= 'A' && s[i1][j1] <= 'Z') {
                        p--;
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
/*
5 3 0
ESN
NWW
SSW
SSS
SSS
*/
