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;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int M = 101;

int H, W;
int sx, sy;
short ac[M][M];
string s[M];
short dp[M][M][M][M];

short get(int a, int b, int c, int d) { //[a,c],[b,d]
	if (a > c || b > d) return 0;
	return ac[c+1][d+1] - ac[c+1][b] - ac[a][d+1] + ac[a][b];
}

short calc(int p, int q, int r, int s) {//dead : bottom p, top r, right r, left s
	if (dp[p][q][r][s] != -1) {
		return dp[p][q][r][s];
	}
	short res = 0;

	if (p + r < H) {
		if (sx - p - 1 >= r) {
			res = max<short>(res, calc(p + 1, q, r, s) + get(sx - p - 1, max(sy - q, s), sx - p - 1, min(sy + s, W - 1 - q)));
		}
		if (sx + r + 1 < H - p) {
			res = max<short>(res, calc(p, q, r + 1, s) + get(sx + r + 1, max(sy - q, s), sx + r + 1, min(sy + s, W - 1 - q)));
		}
	}

	if (q + s < W) {
		if (sy - q - 1 >= s) {
			res = max<short>(res, calc(p, q + 1, r, s) + get(max(sx - p, r), sy - q - 1, min(sx + r, H - 1 - p), sy - q - 1));
		}
		if (sy + s + 1 < W - q) {
			res = max<short>(res, calc(p, q, r, s + 1) + get(max(sx - p, r), sy + s + 1, min(sx + r, H - 1 - p), sy + s + 1));
		}
	}

	return dp[p][q][r][s] = res;
}

int main() {
	cin >> H >> W;
	rep(i, H) cin >> s[i];
	rep(i, H) {
		rep(j, W) {
			ac[i+1][j+1] = ac[i+1][j] + ac[i][j+1] - ac[i][j] + (s[i][j] == 'o');
			if (s[i][j] == 'E') {
				sx = i, sy = j;
			}
		}
	}
	memset(dp, -1, sizeof(dp));

	cout << calc(0, 0, 0, 0) << endl;

	return 0;
}