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>
using namespace std;
const int N=102;
int i,j,k,n,m,ch,x,y,ans;
int a[N][N],A[N][N],B[N][N];
char s[N];
short f[N][N][N][N];
int main() {
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) {
		scanf("%s",s+1);
		for (j=1;j<=m;j++) {
			if (s[j]=='o') a[i][j]=1;
			if (s[j]=='E') x=i,y=j;
		}
	}
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) A[i][j]=a[i][j]+A[i][j-1];
	for (j=1;j<=m;j++)
		for (i=1;i<=n;i++) B[i][j]=a[i][j]+B[i-1][j];
	for (int u=0;u<=n;u++)
		for (int d=0;u+d<n;d++)
			for (int l=0;l<=m;l++)
				for (int r=0;l+r<m;r++) {
					if (x-d<=u+1 && u+1<=x+u) f[u+1][d][l][r]=max(f[u+1][d][l][r],(short) (f[u][d][l][r]+max(0,A[u+1][min(y+l,m-r)]-A[u+1][max(y-r,l+1)-1])));
					if (x-d<=n-d && n-d<=x+u) f[u][d+1][l][r]=max(f[u][d+1][l][r],(short) (f[u][d][l][r]+max(0,A[n-d][min(y+l,m-r)]-A[n-d][max(y-r,l+1)-1])));
					if (y-r<=l+1 && l+1<=y+l) f[u][d][l+1][r]=max(f[u][d][l+1][r],(short) (f[u][d][l][r]+max(0,B[min(x+u,n-d)][l+1]-B[max(x-d,u+1)-1][l+1])));
					if (y-r<=m-r && m-r<=y+l) f[u][d][l][r+1]=max(f[u][d][l][r+1],(short) (f[u][d][l][r]+max(0,B[min(x+u,n-d)][m-r]-B[max(x-d,u+1)-1][m-r])));
				}
	for (int u=0;u<=n;u++)
		for (int d=0;u+d<=n;d++)
			for (int l=0;l<=m;l++)
				for (int r=0;l+r<=m;r++) ans=max(ans,(int) f[u][d][l][r]);
	printf("%d\n",ans);
}