// #pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<cmath>
// #include<cstdio>
// #include<cctype>
// #include<cstring>
// #include<iomanip>
// #include<iostream>
// #include<algorithm>
using namespace std;
#define maxn 400010
#define maxm 2000010
#define ll long long
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define rint register ll
#define uint unsigned ll
#define pir pair <ll ,ll >
#define ull unsigned long long

#define fir first
#define sec second
#define LS(x) ((x)<<1)
#define RS(x) ((x)<<1|1)
#define lowbit(i) (i&-i)
#define MID(l,r) ((l)+(r)>>1)

const ll INF=4e18;
const int BASE=131;
const double eps=1e-8;
const int mod=998244353;
const int inf=1061109567;
const double pi=acos(-1);
const int inv2=(mod+1)>>1;

namespace Math{

	inline ll popcount(ll x){
		x = (x&0x55555555) + ((x>>1)&0x55555555);
		x = (x&0x33333333) + ((x>>2)&0x33333333);
		x = (x&0x0F0F0F0F) + ((x>>4)&0x0F0F0F0F);
		x = (x&0x00FF00FF) + ((x>>8)&0x00FF00FF);
		x = (x&0x0000FFFF) + ((x>>16)&0x0000FFFF);
		return x;
	}

	inline ll F(ll x,ll p){return x>=p?x-p:x;}
	inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
	inline ll ksm(ll x,ll t,ll p){
		ll res=1;while(t){
			if(t&1)res=1LL*res*x%p;
			x=1LL*x*x%p;t>>=1;
		}return res;
	}
	
}

using Math::popcount;
using Math::ksm;
using Math::F;

template < typename tp >
inline void read ( tp & dig ) {
	char ch=getchar();ll flag=0;dig=0;
	while(!isdigit(ch)){ if(ch=='-')flag=1;ch=getchar(); }
	while(isdigit(ch))dig=dig*10+ch-'0',ch=getchar();
	if(flag)dig=-dig;
}

template < typename tp , typename ...Args >
inline void read ( tp & dig , Args & ...args ){
	read(dig);read(args...);
}

int sum[110][110],f[110][110][110];
int n,m,ex,ey;
char s[110][110];

inline int get(int x1,int y1,int x2,int y2){
    return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}

int main()
{

#ifndef ONLINE_JUDGE
	// freopen("a.out","w",stdout);
#endif

    read(n);read(m);
    for(int i=1;i<=n;++i)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            if(s[i][j]=='E')ex=i,ey=j;
            else sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(s[i][j]=='o');
    for(rint i=0;i<=n;++i)
        for(rint j=0;j<=m;++j)
            for(rint k=0;k<=m;++k)
                f[i][j][k]=-inf;
    f[0][0][0]=0;int ans=0;
    for(rint i=0;i<=n;++i){
        if(ex-i<1)break;
        for(rint j=0;j<=n;++j){
            if(ex+j>n)break;
            int up=max(ex-i,1+j),dn=min(ex+j,n-i);
            if(up>dn)continue;
            for(rint k=0;k<=m;++k){
                if(ey-k<1)break;
                for(rint l=0;l<=m;++l){
                    if(ey+l>m)break;
                    int lt=max(ey-k,1+l),rt=min(ey+l,m-k);
                    if(lt>rt)continue;
                    ans=max(ans,f[j][k][l]);
                    if(i+j<n-ex)f[j+1][k][l]=max(f[j+1][k][l],f[j][k][l]+get(ex+j+1,lt,ex+j+1,rt));
                    if(k+l<ey-1)f[j][k+1][l]=max(f[j][k+1][l],f[j][k][l]+get(up,ey-k-1,dn,ey-k-1));
                    if(k+l<m-ey)f[j][k][l+1]=max(f[j][k][l+1],f[j][k][l]+get(up,ey+l+1,dn,ey+l+1));
                    if(i+j<ex-1)f[j][k][l]=max(f[j][k][l],f[j][k][l]+get(ex-i-1,lt,ex-i-1,rt));
                }
            }
        }
    }printf("%d\n",ans);
    return 0;

}

Measured memory_bytes: 5120