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>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=105;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int h,w,sx,sy,a[MAXN][MAXN],b[MAXN][MAXN],c[MAXN][MAXN],F[2][MAXN][MAXN][MAXN];char s[MAXN];
inline void upd(int&x,int y){y>x?x=y:0;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	h=read(),w=read();
	Rep(i,1,h){
		scanf("%s",s+1);
		Rep(j,1,w){
			if(s[j]=='E')sx=i,sy=j;
			a[i][j]=s[j]=='o',b[i][j]=a[i][j]+b[i][j-1],c[i][j]=a[i][j]+c[i-1][j];
		}
	}
	int now=0;
	Rep(u,0,sx-1){
		Rep(d,0,h-sx)Rep(l,0,sy-1)Rep(r,0,w-sy){
			if(u<sx-1)upd(F[now^1][d][l][r],F[now][d][l][r]+(sx-u-1>d?min(sy+r,w-l)>=max(sy-l,r+1)?b[sx-u-1][min(sy+r,w-l)]-b[sx-u-1][max(sy-l,r+1)-1]:0:0));
			if(d<h-sx)upd(F[now][d+1][l][r],F[now][d][l][r]+(sx+d+1<h-u+1?min(sy+r,w-l)>=max(sy-l,r+1)?b[sx+d+1][min(sy+r,w-l)]-b[sx+d+1][max(sy-l,r+1)-1]:0:0));
			if(l<sy-1)upd(F[now][d][l+1][r],F[now][d][l][r]+(sy-l-1>r?min(sx+d,h-u)>=max(sx-u,d+1)?c[min(sx+d,h-u)][sy-l-1]-c[max(sx-u,d+1)-1][sy-l-1]:0:0));
			if(r<w-sy)upd(F[now][d][l][r+1],F[now][d][l][r]+(sy+r+1<w-l+1?min(sx+d,h-u)>=max(sx-u,d+1)?c[min(sx+d,h-u)][sy+r+1]-c[max(sx-u,d+1)-1][sy+r+1]:0:0));
		}if(u==sx-1)break;
		memset(F[now],0,sizeof(now)),now^=1;
	}cout<<F[now][h-sx][sy-1][w-sy]<<'\n';
	return 0;
}