using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

struct Point
{
    public int x, y;
    public Point(int yy, int xx)
    {
        y = yy;
        x = xx;
    }
}

class Program
{
    static int cmp(HashSet<Point> a, HashSet<Point> b)
    {
        return b.Count - a.Count;
    }
    static void Main()
    {
        StreamReader read = new StreamReader(new FileStream("robots.in", FileMode.Open));
        StreamWriter write = new StreamWriter(new FileStream("robots.out", FileMode.Create));
        int[] f = read.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        int n = f[0], m = f[1], g = f[2];
        string[] s = new string[n];
        for (int i = 0; i < n; i++)
            s[i] = read.ReadLine();
        bool[,] was = new bool[n, m];
        int[,] cycle = new int[n, m];
        List<HashSet<Point>> ans = new List<HashSet<Point>>();
        List<int> k = new List<int>();
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
            {
                if (!was[i, j])
                {
                    int x = j, y = i;
                    bool[,] wwas = new bool[n, m];
                    while (!was[y, x])
                    {
                        was[y, x] = wwas[y, x] = true;
                        if (s[y][x] == 'N')
                        {
                            y--;
                            //c[c.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'n')
                            y--;
                        else if (s[y][x] == 'S')
                        {
                            y++;
                            //c[c.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 's')
                            y++;
                        else if (s[y][x] == 'E')
                        {
                            x++;
                            //c[c.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'e')
                            x++;
                        else if (s[y][x] == 'W')
                        {
                            x--;
                            //c[c.Count - 1].Add(new Point(y, x));
                        }
                        else
                            x--;
                    }
                    if (!wwas[y, x])
                        continue;
                    ans.Add(new HashSet<Point>());
                    k.Add(0);
                    int yy = y, xx = x;
                    do
                    {
                        cycle[y, x] = ans.Count;
                        if (s[y][x] == 'N')
                        {
                            y--;
                            ans[ans.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'n')
                        {
                            y--;
                            k[k.Count - 1]++;
                            ans[ans.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'S')
                        {
                            y++;
                            ans[ans.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 's')
                        {
                            y++;
                            k[k.Count - 1]++;
                            ans[ans.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'E')
                        {
                            x++;
                            ans[ans.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'e')
                        {
                            x++;
                            k[k.Count - 1]++;
                            ans[ans.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'W')
                        {
                            x--;
                            ans[ans.Count - 1].Add(new Point(y, x));
                        }
                        else
                        {
                            x--;
                            k[k.Count - 1]++;
                            ans[ans.Count - 1].Add(new Point(y, x));
                        }
                    } while (y != yy || x != xx);
                }
            }
//        int[,] t = new int[n, m];
        bool[,] gg = new bool[n, m];
        for (int i = 0; i < n; i ++)
            for (int j = 0; j < m; j ++)
                if (cycle[i, j] == 0 && !gg[i, j])
                {
                    int x = j, y = i, kk = 0;
                    while (cycle[y, x] == 0)
                    {
                        
                        gg[y, x] = true;
                        if (s[y][x] == 'N')
                        {
                            y--;
                            if (!gg[y, x])
                                kk++;
                            //c[c.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'n')
                            y--;
                        else if (s[y][x] == 'S')
                        {
                            y++;
                            if (!gg[y, x])
                                kk++;
                            //c[c.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 's')
                            y++;
                        else if (s[y][x] == 'E')
                        {
                            x++;
                            if (!gg[y, x])
                                kk++;
                            //c[c.Count - 1].Add(new Point(y, x));
                        }
                        else if (s[y][x] == 'e')
                            x++;
                        else if (s[y][x] == 'W')
                        {
                            x--;
                            if (!gg[y, x])
                                kk++;
                            //c[c.Count - 1].Add(new Point(y, x));
                        }
                        else
                            x--;
                    }
                    k[cycle[y, x] - 1] = Math.Max(0, k[cycle[y, x] - 1] - kk);
                }
        int kkk = 0;
        for (int i = 0; i < k.Count; i++)
            kkk -= k[i];
        for (int i = 0; i < ans.Count; i++)
            kkk += ans[i].Count;
        write.WriteLine(kkk);
        read.Close();
        write.Close();
        }
    }