#include<bits/stdc++.h>
#define N 105
using namespace std;
#define X(x,u,v) (b[x][v]-b[x][(u)-1])
#define Y(x,u,v) (a[v][x]-a[(u)-1][x])
int n,m,u,v;short dp[N][N][N][N],a[N][N],b[N][N],Ans;
char s[N];
void upd(short &x,short y)
{
	x=max(x,y);
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for (int j=1;j<=m;j++)
		{
			if (s[j]=='E') u=i,v=j;
			if (s[j]=='o') a[i][j]=b[i][j]=1;
			a[i][j]+=a[i-1][j];
			b[i][j]+=b[i][j-1];
		}
	}
	/*
	dp[x1][x2][y1][y2] ->
	*/
	for (int i=0;i<n;i++)
	for (int j=0;j<m;j++)
	{
		for (int x1=1;x1+i<=n;x1++)
		for (int y1=1;y1+j<=m;y1++)
		{
			int x2=x1+i,y2=y1+j;
			short tmp=dp[x1][x2][y1][y2];
			/*if (x1+(n-u)<x2||x2-(u-1)>x1||y1+(m-v)<y2||y2-(v-1)>y1)continue;
			cout<<x1<<' '<<x2<<' '<<y1<<' '<<y2<<endl;*/
			upd(Ans,dp[x1][x2][y1][y2]);
			int _x1=max(1,x2-(u-1)),_x2=min(n,x1+(n-u)),_y1=max(1,y2-(v-1)),_y2=min(m,y1+(m-v));
			//_x1=min()
			if (_x1>_x2||_y1>_y2)continue;
			
			if (x1>1&&_x1<x1) upd(dp[x1-1][x2][y1][y2],tmp+X(x1-1,max(y1,_y1),min(y2,_y2)));
			if (x2<n&&_x2>x2) upd(dp[x1][x2+1][y1][y2],tmp+X(x2+1,max(y1,_y1),min(y2,_y2)));
			if (y1>1&&_y1<y1) upd(dp[x1][x2][y1-1][y2],tmp+Y(y1-1,max(x1,_x1),min(x2,_x2)));
			if (y2<m&&_y2>y2) upd(dp[x1][x2][y1][y2+1],tmp+Y(y2+1,max(x1,_x1),min(x2,_x2)));
		}
	}
	printf("%d\n",(int)Ans);
}