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];
        List<HashSet<Point>> c = new List<HashSet<Point>>();
        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];
                    c.Add(new HashSet<Point>());
                    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;
                    int yy = y, xx = x;
                    do
                    {
                        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--;
                    } while (y != yy || x != xx);
                }
            }
        c.Sort(cmp);
        HashSet<Point> ans = new HashSet<Point>();
        foreach (Point i in c[0])
            ans.Add(i);
        for (int i = 1; i < c.Count; i++)
        {
            bool yes = false;
            foreach (Point j in c[i])
                if (ans.Contains(j))
                {
                    yes = true;
                    break;
                }
            if (!yes)
                foreach (Point j in c[i])
                    ans.Add(j);
        }
        write.WriteLine(ans.Count);
        read.Close();
        write.Close();
    }
}