#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define mt make_tuple
#define ins insert
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> tt;

const int N = 100 + 5;

int n, m, g;
int tim[N][N];
char to[N][N];
int cycleNum[N][N];
int cycleCounttt[N * N];
bool isRobot[N][N];
int currTime = 0;
int tarA, tarB;
int cycleA, cycleB;
int cyclin = 0;
int cycleSize = 0;
int cycleCnt = 0;
bool isCycle = false;
int ans = 0;

void enableCycle(int a, int b) {
    cycleNum[a][b] = cycleCnt;
    if (a == cycleA && b == cycleB && cyclin > 0)
        return;

    cyclin++;
    cycleSize++;

    if (to[a][b] == 'n') {
        enableCycle(a - 1, b);
    } else if (to[a][b] == 's') {
        enableCycle(a + 1, b);
    } else if (to[a][b] == 'e') {
        enableCycle(a, b + 1);
    } else if (to[a][b] == 'w') {
        enableCycle(a, b - 1);
    }
}

int dfs(int a, int b) {
    if (currTime == tim[a][b]) {
        if (cycleNum[a][b] == 0) {
            cycleCnt++;
            cycleA = a;
            cycleB = b;
            cyclin = 0;
            cycleSize = 0;
            enableCycle(a, b);
            cycleCounttt[cycleCnt] = cycleSize;
            return cycleCnt;
        } else {
            return cycleNum[a][b];
        }
    }

    tim[a][b] = currTime;

    if (to[a][b] == 'n') {
        dfs(a - 1, b);
    } else if (to[a][b] == 's') {
        dfs(a + 1, b);
    } else if (to[a][b] == 'e') {
        dfs(a, b + 1);
    } else if (to[a][b] == 'w') {
        dfs(a, b - 1);
    }
}

bool isInCycle(int a, int b) {
    isCycle = false;
    currTime++;
    tarA = a;
    tarB = b;
    int num = dfs(a, b);
    if (cycleCounttt[num] > 0 && isRobot[a][b]) {
        ans++;
        cycleCounttt[num]--;
    }
    return isCycle;
}

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

    memset(cycleNum, 0, sizeof(cycleNum));
    memset(tim, 0, sizeof(tim));
    memset(cycleCounttt, 0, sizeof(cycleCounttt));
    memset(isRobot, false, sizeof(isRobot));

    cin >> n >> m >> g;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int z = 0; z < m; z++) {
            to[i][z] = (char)tolower(s[z]);
            if (s[z] < 'a' || s[z] > 'z')
                isRobot[i][z] = true;
            else
                isRobot[i][z] = false;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int z = 0; z < m; z++) {
            isInCycle(i, z);
        }
    }

    cout << ans;
}