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>

const int MAXN = 110;
const int NINF = 0xcfcfcfcf;
char buf[MAXN];
int H, W, dp[2][MAXN][MAXN][MAXN];
int pre[MAXN][MAXN];
void getmax(int & x, int y) { x < y ? x = y : 0; }
struct M {
	int l, r, u, d;
	M(int a1, int a2, int a3, int a4) {
		l = a1, r = a2, u = a3, d = a4;
	}
} ;
inline int gm(int x) { return x < 0 ? 0 : x; }
inline int in(M a, M b) {
	a.l = std::max(a.l, b.l);
	a.u = std::max(a.u, b.u);
	a.r = std::min(a.r, b.r);
	a.d = std::min(a.d, b.d);
	if (a.l > a.r || a.u > a.d) return 0;
	return pre[a.d][a.r] - pre[a.d][a.l - 1] - pre[a.u - 1][a.r] + pre[a.u - 1][a.l - 1];
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> H >> W;
	int X, Y;
	for (int i = 1; i <= H; ++i) {
		std::cin >> buf + 1;
		for (int j = 1; j <= W; ++j) {
			if (buf[j] == 'E') Y = i, X = j;
			else if (buf[j] == 'o') pre[i][j] = 1;
			pre[i][j] += pre[i][j - 1];
		}
	}
	for (int i = 1; i <= H; ++i)
		for (int j = 1; j <= W; ++j)
			pre[i][j] += pre[i - 1][j];
	int ans = 0;
	int now = 1, lst = 0;
	memset(dp, 0xcf, sizeof dp);
	dp[now][0][0][0] = 0;
	for (int u = 0; u < Y; ++u) {
		std::swap(lst, now);
		for (int d = 0; d <= H - Y; ++d)
		for (int l = 0; l < X; ++l)
		for (int r = 0; r <= W - X; ++r) {
			int & f = dp[now][d][l][r] = 0, t;
			M lim(r + 1, W - l, d + 1, H - u);
			if (u) {
				t = in(M(X - l, X + r, Y - u, Y - u), lim);
				getmax(f, dp[lst][d][l][r] + t);
			}
			if (d) {
				t = in(M(X - l, X + r, Y + d, Y + d), lim);
				getmax(f, dp[now][d - 1][l][r] + t);
			}
			if (l) {
				t = in(M(X - l, X - l, Y - u, Y + d), lim);
				getmax(f, dp[now][d][l - 1][r] + t);
			}
			if (r) {
				t = in(M(X + r, X + r, Y - u, Y + d), lim);
				getmax(f, dp[now][d][l][r - 1] + t);
			}
			getmax(ans, f);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}