You are given a grid with H rows and W columns. Each cell in the grid has a specific state represented by a character as follows:
. : This cell is empty.
o : This cell contains a robot.
E : This cell contains the exit. The exit E occurs exactly once in the entire grid.
Your goal is to help Snuke salvage as many robots as possible by performing the following operation:
Select one of the four possible directions: up, down, left, or right.
All remaining robots will move one cell in the selected direction, unless a robot would step outside of the grid. In that case, the robot will explode and disappear from the grid.
If a robot moves to the exit cell, it will be salvaged and immediately removed from the grid.
Your task is to determine the maximum number of robots that can be salvaged.
Input Format
The first line contains two integers, H and W, representing the number of rows and columns in the grid.
Each of the following H lines contains a string of length W, representing the state of each row in the grid.
Constraints:
1 ≤ H, W ≤ 100
The grid will contain exactly one exit represented by E.
Output Format
Output a single integer, the maximum number of robots that can be salvaged.
Example
Input
text
3 3
.o.
.oE
...
Output
text
2
Explanation
In this example, both robots can be salvaged by moving them to the exit simultaneously.
Solution Placement
Please place your solution in the /app/ directory.
Important: place your implementation at /app/solution.py so the verifier can run it.