Karel wants to enter his robot Karel in a robot contest. The goal of the contest is to escape from a maze. The maze is a grid W squares wide and H squares high, and every square is either a wall or free terrain. Exactly one free square holds the exit.
The robot understands three commands: Step, Right, and Left. Step moves the robot one square forward in the direction it faces. If the square directly ahead is a wall or lies outside the maze, the robot does not move. Right turns the robot 90 degrees clockwise, and Left turns it 90 degrees counterclockwise. The robot has memory for a program of at most 10 commands. After the last command runs, the robot continues from the beginning of the program.
The robot starts on some free square. Its starting square is unknown, but it faces up (towards the neighboring square one row above). Karel wants a program that makes the robot escape from any starting square, meaning the robot reaches the exit at some point while the program runs.
Given the maze and the program, count the starting squares from which the robot escapes.
The input holds several test cases and continues to the end of the file.
The first line of each test case has two space separated integers H and W (1≤H,W≤100). Each of the next H lines has exactly W characters describing the maze. The character X is a wall, the character . is free terrain, and the character E is the free square with the exit.
The next line has the program length L (1≤L≤10). The last line of the test case has the L commands of the program. The character S stands for Step, the character L for Left, and the character R for Right.
Print one line for each test case. Print OK if the robot escapes from every starting square. Otherwise print the number of starting squares from which the robot escapes. The exit square counts as a starting square, and a robot that starts there is already at the exit, so it escapes.