private void run() {
        Scanner scn = new Scanner(System.in);
        String line = scn.nextLine();
        while (!line.trim().equals("0 0 0")) {
            String input[] = line.trim().split(" ");
            stickers = 0;
            lr = -1;
            cr = -1;
            lin = Integer.parseInt(input[0]);
            col = Integer.parseInt(input[1]);
            grid = new char[lin][];
            for (int l = 0; l < lin; l++) {
                grid[l] = scn.nextLine().toCharArray();
                if (lr == -1) {
                    for (int c = 0; c < col; c++) {
                        if (grid[l][c] == 'N' || grid[l][c] == 'S'
                                || grid[l][c] == 'L' || grid[l][c] == 'O') {
                            lr = l;
                            cr = c;
                            or = grid[l][c];
                        }
                    }
                }
            }

            // Começa a simulação...
            String commands = scn.nextLine();
            for (char comm : commands.toCharArray()) {
                apply(comm);
            }

            System.out.println(stickers);

            line = scn.nextLine();
        }
    }