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

void dfs(int i, int j, int prev_path, vector < vector < int > >& path, vector < vector < int > >& gr)
{
    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);
        }
        break;
    case 1:
        if (path[i][j + 1] == -1)
        {
            dfs(i, j + 1, prev_path + 1, path, gr);
        }
        break;
    case 2:
        if (path[i + 1][j] == -1)
        {
            dfs(i + 1, j, prev_path + 1, path, gr);
        }
        break;
    case 3:
        if (path[i][j - 1] == -1)
        {
            dfs(i, j - 1, prev_path + 1, path, gr);
        }
        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);
    int n, m, g, sum = 0, max = 0;
    char asd;
    cin >> n >> m >> g;
    vector < vector < int > > a(n, vector < int >(m));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> asd;
            if ('A' <= asd && asd <= 'Z')
            {
                asd = asd - 'A' + 'a';
                sum++;
            }
            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 < int > > used(n, vector < int >(m, 1));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            vector < vector < int > > path(n, vector < int >(m, -1));
            dfs(i, j, -2, path, a);
            if (path[i][j] != -1 && used[i][j])
            {
                max += path[i][j];
            }
            if (path[i][j] != -1){
            for (int x = 0; x < n; x++)
            {
                for (int y = 0; y < m; y++)
                {
                    if (path[i][j])
                    {
                        used[i][j] = 0;
                    }
                }
            }}
        }
    }
    cout << min(max + 1, sum) << endl;
    return 0;
}
