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 <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 105;

int f[MAX_N][MAX_N][MAX_N], g[MAX_N][MAX_N][MAX_N];
int H, W, A[MAX_N][MAX_N], eX, eY;

inline void update(int &x, int y) {
  if (x < y) x = y;
}

inline int get_num(int a, int b, int c, int d) {
  if (a > c || b > d) return 0;
  return A[c][d] - A[a - 1][d] - A[c][b - 1] + A[a - 1][b - 1];
}

int main() {
  scanf("%d%d", &H, &W);
  for (int i = 1; i <= H; ++i) {
    static char S[MAX_N];
    scanf("%s", S + 1);
    for (int j = 1; j <= W; ++j) {
      A[i][j] = A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1] + (S[j] == 'o');
      if (S[j] == 'E') eX = i, eY = j;
    }
  }

  f[0][0][0] = 0;
  int res = 0;
  for (int i = 0; i < H; ++i) {
    memset(g, 0, sizeof g);
    for (int j = 0; j + i <= H; ++j)
      for (int k = 0; k < W; ++k)
	for (int m = 0; m + k <= W; ++m) {
	  res = max(res, f[j][k][m]);
	  int U = i + 1, D = H - j, L = k + 1, R = W - m;
	  int u = eX - j, d = eX + i, l = eY - m, r = eY + k;
	  if (U > D || L > R) continue;
	  if (d + 1 <= D && d + 1 >= U) update(g[j][k][m], f[j][k][m] + get_num(d + 1, max(L, l), d + 1, min(R, r)));
	  if (u - 1 >= U && u - 1 <= D) update(f[j + 1][k][m], f[j][k][m] + get_num(u - 1, max(L, l), u - 1, min(R, r)));
	  if (r + 1 <= R && r + 1 >= L) update(f[j][k + 1][m], f[j][k][m] + get_num(max(U, u), r + 1, min(D, d), r + 1));
	  if (l - 1 >= L && l - 1 <= R) update(f[j][k][m + 1], f[j][k][m] + get_num(max(U, u), l - 1, min(D, d), l - 1));
	}
    memcpy(f, g, sizeof f);
  }

  printf("%d\n" , res);
  return 0;
}