#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

class DSU{

public:
    int* parent;
    int* alt;
    int total;
    void resize(int gettotal) {

        total = gettotal;
        parent = new int[total];
        alt = new int[total];
        for(int i=0; i<total; ++i) {
            parent[i] = i;
            alt[i] = 1;
        }

    }

    int getRoot(int v) {

        if(parent[v] != v)
            parent[v] = getRoot(parent[v]);
        return parent[v];

    }

    void merge(int a, int b) {

        a = getRoot(a);
        b = getRoot(b);
        if(a == b)
            return;
        if(alt[a] < alt[b])
            swap(a,b);
        parent[b] = a;
        if(alt[a] == alt[b])
            ++alt[a];

    }

    char isCommon(int a, int b) {

        return (getRoot(a) == getRoot(b));

    }

};

int height, width;
int inputparam;
int totalCells = height*width;
int* cells;
char* isRobot;
char* used;
DSU comps;

int dfs2_steps;
int dfs2_start;


void dfs(int v) {

    used[v] = 1;

    if(!used[cells[v]])
        dfs(cells[v]);
    comps.merge(v, cells[v]);

}

void dfs2(int v) {

    int already = dfs2_steps;
    used[v] = 1;
    if(!used[cells[v]]) {

        ++dfs2_steps;
        dfs2(cells[v]);
        if(dfs2_start != -1) {

            if(dfs2_start == v)
                dfs2_steps -= already;
            return;

        }

    }
    else {

        ++dfs2_steps;
        dfs2_start = cells[v];

    }

}

int main() {

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

    cin >> height >> width >> inputparam;

    totalCells = height*width;

    cells = new int[totalCells];
    isRobot = new char[totalCells];

    for(int i=0; i<totalCells; ++i)
        isRobot[i] = 0;

    for(int i=0; i<height; ++i) {

        for(int j=0; j<width; ++j) {

            int id = i*width + j;

            char c = 0;
            while( !(c >= 'a' && c <= 'z' || c >= 'A' && c <='Z') )
                c = cin.get();

            if(c >= 'A' && c <= 'Z') {

                isRobot[id] = 1;
                c += ((int)('a')) - ((int)('A'));

            }

            switch(c) {

            case 'n':
                cells[id] = id-width;
                break;
            case 's':
                cells[id] = id+width;
                break;
            case 'w':
                cells[id] = id-1;
                break;
            case 'e':
                cells[id] = id+1;
                break;

            }

        }

    }

    comps.resize(totalCells);
    used = new char[totalCells];

    for(int i=0; i<totalCells; ++i)
        used[i] = 0;

    for(int i=0; i<totalCells; ++i)
        if(!used[i])
            dfs(i);

    vector<int>* complists = new vector<int>[totalCells];
    for(int i=0; i<totalCells; ++i)
        complists[comps.getRoot(i)].push_back(i);

    for(int i=0; i<totalCells; ++i)
        used[i] = 0;

    int ans = 0;

    for(int z=0; z<totalCells; ++z) {

        vector<int>& comp = complists[z];
        if(comp.empty())
            continue;

        dfs2_start = -1;
        dfs2_steps = 0;
        dfs2(z);
        int totalRobots = 0;
        for(int i=0; i<comp.size(); ++i)
            if(isRobot[comp[i]])
                ++totalRobots;

        ans += min(totalRobots, dfs2_steps);

        //cout << "comp print:\n";
        //for(int i=0; i<comp.size(); ++i)
        //    cout << comp[i] << ' ';
        //cout << endl;
        //cout << "cycle size: " << dfs2_steps << endl;
        //cout << "number of robots: " << totalRobots << endl;

    }

    cout << ans << endl;

    return 0;

}
