#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define s second
#define f first

void dfs(char i, char j, char prev_path, vector < vector < int16_t > >& path, vector < vector < char > >& gr, vector < vector < char > >& used, char a = false)
{
    if (!a && used[i][j] == 0)
        return;
    path[i][j] = prev_path + 1;
    switch (gr[i][j])
    {
    case 0:
        if (path[i - 1][j] == -1)
        {
            dfs(i - 1, j, prev_path + 1, path, gr, used, a);
        }
        break;
    case 1:
        if (path[i][j + 1] == -1)
        {
            dfs(i, j + 1, prev_path + 1, path, gr, used, a);
        }
        break;
    case 2:
        if (path[i + 1][j] == -1)
        {
            dfs(i + 1, j, prev_path + 1, path, gr, used, a);
        }
        break;
    case 3:
        if (path[i][j - 1] == -1)
        {
            dfs(i, j - 1, prev_path + 1, path, gr, used, a);
        }
        break;
    }
}

int main()
{
    #ifndef LOCAL_DEBUG
    freopen("robots.in", "rt", stdin);
    freopen("robots.out", "wt", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int16_t n, m, g, sum = 0, max = 0;
    char asd;
    cin >> n >> m >> g;
    vector < vector < int16_t > > a(n, vector < int16_t >(m));
    vector < vector < int16_t > > is(n, vector < int16_t >(m));
    for (char i = 0; i < n; i++)
    {
        for (char j = 0; j < m; j++)
        {
            cin >> asd;
            if ('A' <= asd && asd <= 'Z')
            {
                asd = asd - 'A' + 'a';
                is[i][j] = 1;
            }
            if (asd == 'n')
            {
                a[i][j] = 0;
            }
            if (asd == 'e')
            {
                a[i][j] = 1;
            }
            if (asd == 's')
            {
                a[i][j] = 2;
            }
            if (asd == 'w')
            {
                a[i][j] = 3;
            }
        }
    }
    vector < vector < char > > used(n, vector < char >(m, 1));
    map < pair < char, char >, int > circles;
    int counter = 0;
    for (char i = 0; i < n; i++)
    {
        for (char j = 0; j < m; j++)
        {
            vector < vector < char > > path(n, vector < char >(m, -1));
            dfs(i, j, -2, path, a, used);
            if (path[i][j] != -1 && used[i][j])
            {
                circles[mp(i, j)] = path[i][j] + 1;
                used[i][j] = 0;
            }
        }
    }
    for (char i = 0; i < n; i++)
    {
        for (char j = 0; j < m; j++)
        {
            if (is[i][j]){
            vector < vector < int16_t > > path(n, vector < int16_t >(m, -1));
            char flag = 1;
            dfs(i, j, -2, path, a, used, true);
            for (char x = 0; x < n && flag; x++)
            {
                for (char y = 0; y < m; y++)
                {
                    if (path[x][y] != -1 && circles[mp(x, y)] > 0)
                    {
                        counter++;
                        circles[mp(x, y)]--;
                        flag = false;
                        break;
                    }
                }
            }
        }}
    }
    cout << counter << endl;
    return 0;
}
