import java.io.*;
import java.util.*;

import javax.swing.text.AbstractDocument.LeafElement;

public class Pr2Robots {
	public static void main(String[] args) throws IOException {
		new Pr2Robots().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	void run() throws IOException {
		in = new BufferedReader(new FileReader("robots.in"));
		out = new PrintWriter("robots.out");
		solve();
		out.flush();
	}
	
	int [][] was;
	int[] cycleLen;
	int[] numToCycle;
//	int[][] distToCycle;
	int[][] numOfCycle;
	char[][] table;
	int[][] stack;
	int[][] numInStack;
	int sz = 0;
	int cycles = 0;
	void dfs(int curi, int curj, int sti, int stj) {
		was[curi][curj] = 1;
		int nexti = curi;
		int nextj = curj;
		stack[sz][0] = curi;
		stack[sz][1] = curj;
		numInStack[curi][curj] = sz;
		sz++;
		if(table[curi][curj] == 'E' || table[curi][curj] =='e' ) {
			nextj++;
		}
		if(table[curi][curj] == 'W' || table[curi][curj] =='w' ) {
			nextj--;
		}
		if(table[curi][curj] == 'N' || table[curi][curj] =='n' ) {
			nexti--;
		}
		if(table[curi][curj] == 'S' || table[curi][curj] =='s' ) {
			nexti++;
		}
		if(was[nexti][nextj] == 1) {
			addCycle(numInStack[nexti][nextj]);
			was[curi][curj] = 2;
			numOfCycle[curi][curj] = cycles-1;
			
			return;
		}else
		if(was[nexti][nextj] == 0) {
			dfs(nexti, nextj, sti, stj);
		}else {
			numToCycle[numOfCycle[nexti][nextj]]++;
		}
		numOfCycle[curi][curj] = numOfCycle[nexti][nextj];
		sz--;
		was[curi][curj] = 2;
	}
	
	void addCycle(int pos) {
		cycleLen[cycles] = sz - pos;
		numToCycle[cycles]++;
		cycles++;
	}

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int g = nextInt();
		table = new char[n][m];
		for(int i = 0; i < n; i++) {
			String s = nextToken();
			for(int j = 0; j < m; j++) {
				table[i][j] = s.charAt(j);
			}
		}
		was = new int[n][m];
		cycleLen = new int[n*m];
		numToCycle = new int[n*m];
//		distToCycle = new int[n][m];
		numOfCycle = new int[n][m];
		stack = new int[n*m][2];
		numInStack = new int[n][m];
		for(int i = 0; i < n; i++) {
			Arrays.fill(numOfCycle[i], -1);
//			numOfCycle
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				if(Character.isUpperCase(table[i][j])) {
					if(was[i][j] == 2) {
						numToCycle[numOfCycle[i][j]]++;
						continue;
					}
					dfs(i, j, i, j);
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < cycles; i++) {
			ans += Math.min(cycleLen[i], numToCycle[i]);
		}
		out.println(ans);
	}
}
