#include<iostream>
#include<cstdio>
using namespace std;

char map[105][105];
int n,m,x,y,ans=0,a[105][105],b[105][105];
short f[105][105][105][105];

int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",map[i]+1);
		for(int j=1;j<=m;j++){
			a[i][j]=a[i][j-1]+(map[i][j]=='o');
			b[i][j]=b[i-1][j]+(map[i][j]=='o');
			if(map[i][j]=='E')x=i,y=j;
		}
	}
	for(int i=x;i>=1;i--)
	for(int j=y;j>=1;j--){
		for(int k=x;k<=n;k++)
		for(int l=y;l<=m;l++){
			if(i>1&&i-1>k-x)ans=max(ans,f[i-1][j][k][l]=max(f[i-1][j][k][l],f[i][j][k][l]+a[i-1][min(l,m-y+j)]-a[i-1][max(j-1,l-y)]));
			if(k<n&&n-k>x-i)ans=max(ans,f[i][j][k+1][l]=max(f[i][j][k+1][l],f[i][j][k][l]+a[k+1][min(l,m-y+j)]-a[k+1][max(j-1,l-y)]));
			if(j>1&&j-1>l-y)ans=max(ans,f[i][j-1][k][l]=max(f[i][j-1][k][l],f[i][j][k][l]+b[min(k,n-x+i)][j-1]-b[max(i-1,k-x)][j-1]));
			if(l<m&&m-l>y-j)ans=max(ans,f[i][j][k][l+1]=max(f[i][j][k][l+1],f[i][j][k][l]+b[min(k,n-x+i)][l+1]-b[max(i-1,k-x)][l+1]));
		}
	}
	printf("%d",ans);
}