#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
int H,W,s1[110][110],s2[110][110],MX1,MX2,MX3,MX4;
char mp[110][110];
struct DP{
	int f[10001000];
	int& operator () (int a,int b,int c,int d){
		return f[a*MX2*MX3*MX4+b*MX3*MX4+c*MX4+d];
	}
}f;
void chmax(int &a,int b){if(b>a) a=b;}
int main(){
	cin>>H>>W;
	int x=0,y=0;
	for(int i=1;i<=H;i++){
		cin>>mp[i]+1;
		for(int j=1;j<=W;j++){
			if(mp[i][j]=='E') x=i,y=j;
			s1[i][j]=s1[i][j-1]+(mp[i][j]=='o');
			s2[j][i]=s2[j][i-1]+(mp[i][j]=='o');
		}
	}
	MX1=x;MX2=H-x+1;MX3=y;MX4=W-y+1;
	int ans=0;
	for(int a=0;a<MX1;a++)
		for(int b=0;b<MX2;b++)
			for(int c=0;c<MX3;c++)
				for(int d=0;d<MX4;d++){
					int U=min(a,MX1-b-1),D=min(b,MX2-a-1),L=min(c,MX3-d-1),R=min(d,MX4-c-1);
					if(MX1-b>a+1) chmax(f(a+1,b,c,d),f(a,b,c,d)+s1[x-a-1][y+R]-s1[x-a-1][y-L-1]);
					if(MX2-a>b+1) chmax(f(a,b+1,c,d),f(a,b,c,d)+s1[x+b+1][y+R]-s1[x+b+1][y-L-1]);
					if(MX3-d>c+1) chmax(f(a,b,c+1,d),f(a,b,c,d)+s2[y-c-1][x+D]-s2[y-c-1][x-U-1]);
					if(MX4-c>d+1) chmax(f(a,b,c,d+1),f(a,b,c,d)+s2[y+d+1][x+D]-s2[y+d+1][x-U-1]);
					chmax(ans,f(a,b,c,d));
				}
	cout<<ans<<'\n';
	return 0;
}