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

using namespace std;

int n, m, g;
char a[1001][1001];
bool used[1001][1001];
bool used2[1001][1001];
int pp[1001][1001];

int main()
{
    ios_base::sync_with_stdio(false);
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m >> g;
    if (g == 1)
    {
        return 0;
    }

    for (int i = 1; i <= n; i++)
    {
        for (int g = 1; g <= m; g++)
        {
            cin >> a[i][g];
        }
    }

    int ans = 0;

    for (int i = 1; i <= n; i++)
    {
        for (int g = 1; g <= m; g++)
        {
            memset(used, 0, sizeof(used));

            int i1 = i;
            int g1 = g;
            int calc = 0;

            for (int j = 1; j <= n * m; j++)
            {
                if (a[i1][g1] == 'S')
                {
                    i1++;
                    calc++;
                } else
                if (a[i1][g1] == 'N')
                {
                    i1--;
                    calc++;
                } else
                if (a[i1][g1] == 'E')
                {
                    g1++;
                    calc++;
                } else
                if (a[i1][g1] == 'W')
                {
                    g1--;
                    calc++;
                } else
                if (a[i1][g1] == 's' )
                {
                    i1++;
                } else
                if (a[i1][g1] == 'n')
                {
                    i1--;
                } else
                if (a[i1][g1] == 'e')
                {
                    g1++;
                } else
                if (a[i1][g1] == 'w')
                {
                    g1--;
                }

                if (used2[i1][g1])
                {
                    if (pp[i1][g1] > 0)
                    {
                        ans++;
                        pp[i1][g1]--;
                    }

                    break;
                }

                if (i1 == i && g1 == g)
                {
                    ans += calc;
                    used2[i][g] = true;
                    pp[i][g] = j - calc;
                }

                if (used[i1][g1])
                {
                    break;
                }

                used[i1][g1] = true;
            }
        }
    }

    cout << ans << endl;
    return 0;
}
