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	105
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char mp[MAXN][MAXN];
int sum[MAXN][MAXN];
int ans[2][MAXN][MAXN][MAXN];
int n, m, x, y;
int getsum(int x, int y, int n, int m) {
	if (x > n || y > m) return 0;
	else return sum[n][m] - sum[n][y - 1] - sum[x - 1][m] + sum[x - 1][y - 1];
}
void update(int &x, int y) {
	x = max(x, y);
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++) {
		scanf("\n%s", mp[i] + 1);
		for (int j = 1; j <= m; j++) {
			if (mp[i][j] == 'E') x = i, y = j;
			if (mp[i][j] == 'o') sum[i][j] = 1;
			sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
		}
	}
	int finalans = 0;
	for (int i = 1, now = 1, last = 0; i <= n; i++, now ^= 1, last ^= 1) {
		for (int j = n; j >= i - 1; j--)
		for (int k = 1; k <= m; k++)
		for (int l = m; l >= k - 1; l--) {
			int ti = x - (n - j), tj = x + (i - 1);
			int tk = y - (m - l), tl = y + (k - 1);
			update(ans[now][j][k][l], ans[last][j][k][l] + getsum(max(tj, i), max(tk, k), min(tj, j), min(tl, l)));
			update(ans[now][j][k][l], ans[now][j + 1][k][l] + getsum(max(ti, i), max(tk, k), min(ti, j), min(tl, l)));
			update(ans[now][j][k][l], ans[now][j][k - 1][l] + getsum(max(ti, i), max(tl, k), min(tj, j), min(tl, l)));
			update(ans[now][j][k][l], ans[now][j][k][l + 1] + getsum(max(ti, i), max(tk, k), min(tj, j), min(tk, l)));
			update(finalans, ans[now][j][k][l]);
		}
		for (int j = n; j >= x; j--)
		for (int k = 1; k <= y; k++)
		for (int l = m; l >= y; l--)
			ans[last][j][k][l] = 0;
	}
	cout << finalans << endl;
	return 0;
}