#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

const int N = 1e3;

int n, m, g;
vector<string> a;
bool used[N][N];
int col[N][N], dist[N][N], len[N * N];
int C = 0;

void allclear() {
    memset(col, -1, sizeof col);
    memset(dist, 0, sizeof dist);
    memset(len, 0, sizeof len);
    memset(used, 0, sizeof used);
    C = 0;
}

int dx(char c) {
    if (tolower(c) == 'w') return -1;
    if (tolower(c) == 'e') return 1;
    return 0;
}

int dy(char c) {
    if (tolower(c) == 'n') return -1;
    if (tolower(c) == 's') return 1;
    return 0;
}

void findcycle(int i, int j, int d) {
    used[i][j] = true;
    dist[i][j] = d;

    int newi = i + dy(a[i][j]);
    int newj = j + dx(a[i][j]);
    if (used[newi][newj] == true) {
        if (col[newi][newj] != -1) {
            col[i][j] = col[newi][newj];
        } else {
            len[C] = dist[i][j] - dist[newi][newj] + 1;
            col[i][j] = C++;
        }
    } else {
        findcycle(newi, newj, d + 1);
        col[i][j] = col[newi][newj];
    }
}

void solve() {
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (!used[i][j]) {
                findcycle(i, j, 0);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (toupper(a[i][j]) == a[i][j]) {
                ans += (len[col[i][j]] > 0);
                len[col[i][j]] = max(len[col[i][j]] - 1, 0);
            }
        }
    }

    printf("%d\n", ans);
}

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

    while (scanf("%d%d%d", &n, &m, &g) == 3) {
        allclear();
        solve();
    }
}
