#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;
struct rob
{
    int x,y,s,nx,ny,ch;
    bool a;
};
rob r[1000040];
int a[1004][1004][2];
int b[1004][1004];

int rec(int x, int y, int nx, int ny)
{
    b[x][y] = nx * 1005 + ny + 1;
    int t1 ,t2;
    t1 = a[x][y][0];
    t2 = a[x][y][1];
    x += t1;
    y += t2;
    if (b[x][y] == nx * 1005 + ny + 1)
    {
        if (x == nx && y == ny)
        {
            return 1;
        }
        else
            return 0;
    }
    else
    if (b[x][y]  >= 0)
    {
        int t1;
        t1 = rec(x,y,nx,ny);
        if (t1 > 0)
        {
            b[x][y] = -1;
            return (t1+1);
        }
        else
        {
            return 0;
        }

    }
    else
        return 0;

}

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


    int n2,f,i,j,n,m,g;
    cin >> n >> m >> g;
    //scanf("%i%i%i",&n,&m,&g);
    f = 0;
    for (i = 0; i<n; i++)
        for (j = 0; j<m; j++)
        {
            char ch;
            //scanf("%c",&ch);
            cin >> ch;
            if (ch > 'A' && ch < 'Z')
            {
                r[f].nx = i;
                r[f].ny = j;
                r[f].x = i;
                r[f].y = j;
                r[f].s = 1;
                r[f].a = true;
                r[f].ch = 0;
                ch = ch + 'a' - 'A';
                b[i][j] = 1;
                f++;
            }
            if (ch == 'n')  a[i][j][0] = -1;
            if (ch == 'e')  a[i][j][1] = 1;
            if (ch == 's')  a[i][j][0] = 1;
            if (ch == 'w')  a[i][j][1] = -1;
        }
    n2 = f;
    long long ot = 0;

    for (i = 0; i<n; i++)
        for (j = 0; j<m; j++)
        {
            if (b[i][j] > 0) ot += rec(i,j,i,j);
        }
    cout << ot << endl;





}
/*
3 4 0
SSSS
EESW
ENWW

3 4 1
SSSS
EsSW
ENwW

2 2 1
SS
NN
*/
