Problem: We have a grid with H rows and W columns. The state of the cell at the i-th (1≤i≤H) row and j-th (1≤j≤W) column is represented by a letter a_{ij}, as follows:

* `.` : This cell is empty.
* `o` : This cell contains a robot.
* `E` : This cell contains the exit. `E` occurs exactly once in the whole grid.



Snuke is trying to salvage as many robots as possible, by performing the following operation some number of times:

* Select one of the following directions: up, down, left, right. All remaining robots will move one cell in the selected direction, except when a robot would step outside the grid, in which case the robot will explode and immediately disappear from the grid. If a robot moves to the cell that contains the exit, the robot will be salvaged and immediately removed from the grid.



Find the maximum number of robots that can be salvaged.

Constraints

* 2≤H,W≤100
* a_{ij} is `.`, `o` or `E`.
* `E` occurs exactly once in the whole grid.

Input

The input is given from Standard Input in the following format:


H W
a_{11}...a_{1W}
:
a_{H1}...a_{HW}


Output

Print the maximum number of robots that can be salvaged.

Examples

Input

3 3
o.o
.Eo
ooo


Output

3


Input

2 2
E.
..


Output

0


Input

3 4
o...
o...
oooE


Output

5


Input

5 11
ooo.ooo.ooo
o.o.o...o..
ooo.oE..o..
o.o.o.o.o..
o.o.ooo.ooo


Output

12

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#define maxn 102
int n, m, XX, YY, ans; 
int a[maxn][maxn], b[maxn][maxn];
short f[maxn][maxn][maxn][maxn];

void Getmax(int &x, int y) { if(y > x) x = y; }
bool Mid(int K, int l, int r) { return (K >= l) && (K <= r); }

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= m; j ++)
        {
            char c; cin >> c; int tem = 0;
            if(c == 'o') tem = 1;
            else if(c == 'E') XX = i, YY = j;
            a[i][j] = a[i][j - 1] + tem;
            b[j][i] = b[j][i - 1] + tem;
        }
    for(int u = 0; u < XX; u ++)
        for(int d = 0; d <= n - XX; d ++)
            for(int l = 0; l < YY; l ++)
                for(int r = 0; r <= m - YY; r ++)
                {
                    int ret = 0, tem1 = XX - u, tem2 = XX + d;
                    int tem3 = YY - l, tem4 = YY + r;
                    int p1 = min(YY + r, m - l), p2 = max(YY - l, r + 1); // line
                    int q1 = min(XX + d, n - u), q2 = max(XX - u, d + 1); // row
                    if(u) Getmax(ret, f[u - 1][d][l][r] + ((Mid(tem1, q2, q1)) ? max(a[tem1][p1] - a[tem1][p2 - 1], 0) : 0));
                    if(d) Getmax(ret, f[u][d - 1][l][r] + ((Mid(tem2, q2, q1)) ? max(a[tem2][p1] - a[tem2][p2 - 1], 0) : 0));
                    if(l) Getmax(ret, f[u][d][l - 1][r] + ((Mid(tem3, p2, p1)) ? max(b[tem3][q1] - b[tem3][q2 - 1], 0) : 0));
                    if(r) Getmax(ret, f[u][d][l][r - 1] + ((Mid(tem4, p2, p1)) ? max(b[tem4][q1] - b[tem4][q2 - 1], 0) : 0)); 
                    f[u][d][l][r] = ret;
                    ans = max(ans, (int) f[u][d][l][r]);
                }
    printf("%d\n", ans);
    return 0;
}