#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 currTime = 0;
int tarA, tarB;
bool isCycle = false;

void dfs(int a, int b) {
    if (a == tarA && b == tarB && currTime == tim[a][b]) {
        isCycle = true;
        return;
    }

    if (currTime == tim[a][b]) {
        return;
    }

    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;
    dfs(a, b);
    return isCycle;
}

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

    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]);
        }
    }

    int ans = 0;

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

    cout << ans;
}