#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<set>

using namespace std;

int main() {
     freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    long long n, m, g;
    cin >> n >> m >> g;
    char a[n][m];
    for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    long long b[n][m];
    for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
            b[i][j] = 0;
        }
    }
    long long ans = 0;
    long long cnt2 = 2;
    for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
                long long cnt = 0;
                long long x1 = i;
                long long y1 = j;
                while (b[x1][y1] == false) {
                    //can[x1][y1] = 1;
                    //cout << x1 << ' ' << y1 << endl;
                    b[x1][y1] = 1;
                    if (a[x1][y1] == 'N' || a[x1][y1] == 'n') {
                        x1--;
                    } else if (a[x1][y1] == 'E' || a[x1][y1] == 'e') {
                        y1++;
                    } else if (a[x1][y1] == 'S' || a[x1][y1] == 's') {
                        x1++;
                    }else if (a[x1][y1] == 'W' || a[x1][y1] == 'w') {
                        y1--;
                    }
                }
                if (x1 == i && y1 == j) {
                    for (long long i = 0; i < n; i++) {
                        for (long long j = 0; j < m; j ++) {
                            if (b[i][j] == 1) {
                                b[i][j] = cnt2;
                            }
                        }
                    }
                    cnt2++;
                } else {
                    for (long long i = 0; i < n; i++) {
                        for (long long j = 0; j < m; j ++) {
                            if (b[i][j] == 1) {
                                b[i][j] = 0;
                            }
                        }
                    }
                }
        }
    }
    long long b1[n][m];
    long long b2[n][m];
    long long dd[cnt2 + 1];
    long long ddd[cnt2 + 1];
    for (long long i = 0; i <= cnt2; i++) {
        dd[i] = 0;
        ddd[i] = 0;
    }
    for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
            b1[i][j] = 0;
            b2[i][j] = 0;
        }
    }
    for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
                long long x1 = i;
                long long y1 = j;
                long long cnt3 = 0;
                while (b1[x1][y1] == false) {
                    //cout << x1 << ' ' << y1 << endl;
                    if (a[x1][y1] >= 'A' && a[x1][y1] <= 'Z' && !b2[i][j]) {
                        cnt3++;
                    }
                    if (b[x1][y1] >= 2) {
                        //cout << "X" << cnt3;
                        dd[b[x1][y1]] += cnt3;
                        cnt3 = 0;
                    }
                    b1[x1][y1] = 1;
                    if (a[x1][y1] == 'N' || a[x1][y1] == 'n') {
                        x1--;
                    } else if (a[x1][y1] == 'E' || a[x1][y1] == 'e') {
                        y1++;
                    } else if (a[x1][y1] == 'S' || a[x1][y1] == 's') {
                        x1++;
                    }else if (a[x1][y1] == 'W' || a[x1][y1] == 'w') {
                        y1--;
                    }
                }
                for (long long i = 0; i < n; i++) {
                    for (long long j = 0; j < m; j++) {
                        if (b1[i][j] == 1) {
                            b2[i][j] = 1;
                            b1[i][j] = 0;
                        }
                    }
                }

        }
    }
    ans = 0;
    long long cnt1 = 0;
    for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < m; j++) {
           // cout << b[i][j] << ' ';
            if (b[i][j] >= 2) {
                ddd[b[i][j]]++;
            }
        }
        //cout << endl;
    }
    for (long long i = 0; i < cnt2 + 1; i++) {
          //  cout << dd[i] << ' ';
        ans += min(dd[i], ddd[i]);
    }
    cout << ans;
}
