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

public class b1 {
	String fileName = "robots";

	static int dx[] = { 1, 0, -1, 0 };
	static int dy[] = { 0, 1, 0, -1 };
	static int a[][];
	static ArrayList<Integer> robotsx;
	static ArrayList<Integer> robotsy;
	static int color[][];
	static ArrayDeque<Integer> curx;
	static ArrayDeque<Integer> cury;

	static int len[][];
	static int val[][];
	static int number[][];
	static int cnt;
	static int count[];

	static void dfs(int x, int y, int value) {
		color[x][y] = 0;
		val[x][y] = value;
		curx.addLast(x);
		cury.addLast(y);

		int nextx = x + dx[a[x][y]];
		int nexty = y + dy[a[x][y]];

		if (color[nextx][nexty] == 0) {
			count[cnt] = val[x][y] - val[nextx][nexty] + 1;
			for (int i = curx.size() - 1; i > -1; i--) {
				number[curx.getLast()][cury.getLast()] = cnt;
				len[curx.pollLast()][cury.pollLast()] = val[x][y] - val[nextx][nexty] + 1;
				cnt++;

			}
		} else if (color[nextx][nexty] == -1) {
			dfs(nextx, nexty, value + 1);
			len[x][y] = len[nextx][nexty];
			number[x][y] = number[nextx][nexty];
		} else {
			len[x][y] = len[nextx][nexty];
			number[x][y] = number[nextx][nexty];
		}

		color[x][y] = 1;
	}

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int g = nextInt();
		cnt = 0;

		a = new int[n][m];
		robotsx = new ArrayList();
		robotsy = new ArrayList();
		color = new int[n][m];
		len = new int[n][m];
		curx = new ArrayDeque();
		cury = new ArrayDeque();
		val = new int[n][m];
		number = new int[n][m];
		count = new int[n];

		for (int i = 0; i < n; i++) {
			String s = nextToken();
			Arrays.fill(color[i], -1);

			for (int j = 0; j < m; j++) {
				if (s.charAt(j) == 's' || s.charAt(j) == 'S') {
					a[i][j] = 0;
				}
				if (s.charAt(j) == 'e' || s.charAt(j) == 'E') {
					a[i][j] = 1;
				}
				if (s.charAt(j) == 'n' || s.charAt(j) == 'N') {
					a[i][j] = 2;
				}
				if (s.charAt(j) == 'w' || s.charAt(j) == 'W') {
					a[i][j] = 3;
				}

				if (s.charAt(j) >= 'A' && s.charAt(j) <= 'Z') {
					robotsx.add(i);
					robotsy.add(j);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (color[i][j] == -1) {
					dfs(i, j, 0);
				}
			}
		}

		if (g == 0) {
			long ans = 0;

			for (int i = 0; i < robotsx.size(); i++) {
				int x = robotsx.get(i);
				int y = robotsy.get(i);

				if (count[number[x][y]] > 0) {
					ans++;
					count[number[x][y]]--;
				}
			}

			out.println(ans);
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader(fileName + ".in"));
			out = new PrintWriter(fileName + ".out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

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

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

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		new b1().run();
	}

}