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

public class Robots {
    String fileName = "robots";

    ArrayList<Cycle> cycles;
    int n, m, num = 0;
    char[][] table;
    int[][] number;

    public void solve() throws IOException {
        n = nextInt();
        m = nextInt();
        int g = nextInt();
        table = new char[n][m];
        HashSet<Integer> robots = new HashSet<>();

        for (int i = 0; i < n; i++) {
            char[] str = br.readLine().toCharArray();
            for (int j = 0; j < m; j++) {
                if (str[j] < 'Z') {
                    table[i][j] = (char) (str[j] + 'a' - 'A');
                    robots.add(i * m + j);
                } else {
                    table[i][j] = str[j];
                }
            }
        }

        cycles = new ArrayList<>();
        visited = new boolean[n * m];
        number = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (!visited[i * m + j]) {
                    vis = new HashSet<>();
                    path = new ArrayList<>();
                    dfs(i, j);
                }
            }
        }

        Cycle[] c = new Cycle[cycles.size()];
        for (Cycle cycle : cycles) {
            c[cycle.num] = cycle;
        }

        int result = 0;
        for (int robot : robots) {
            int t = number[robot / m][robot % m];
            if (c[t].length > 0) {
                c[t].length--;
                result++;
            }
        }

        out.println(result);
    }

    boolean[] visited;
    HashSet<Integer> vis;
    ArrayList<Integer> path;

    private int dfs(int x, int y) {
        int v = x * m + y;
        if (visited[v]) {
            if (vis.contains(v)) {
                cycles.add(new Cycle(num, path.size() - path.indexOf(v)));
                number[x][y] = num;
                num++;
                return num - 1;
            } else {
                return number[x][y];
            }
        } else {
            visited[v] = true;
            path.add(v);
            vis.add(v);
            switch (table[x][y]) {
                case 'w':
                    number[x][y] = dfs(x, y - 1);
                    break;
                case 'e':
                    number[x][y] = dfs(x, y + 1);
                    break;
                case 'n':
                    number[x][y] = dfs(x - 1, y);
                    break;
                case 's':
                    number[x][y] = dfs(x + 1, y);
            }
            path.remove(path.size() - 1);
            vis.remove(v);
            return number[x][y];
        }
    }

    private class Cycle {
        int num, length;

        public Cycle(int num, int length) {
            this.num = num;
            this.length = length;
        }
    }

    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 Robots().run();
    }

}