#include<iostream>
#include<cstring>
#include<cstdio>
#include<bitset>
#define MN 100
#define ull unsigned long long
#define F(a,b,c,d) ((a>b||c>d)?ans:f[num[a][b]][num2[c][d]])
#define N 65535
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
char st[MN+5][MN+5];
int f[5505][5505],num[MN+5][MN+5],num2[MN+5][MN+5],n,m,ans,cnt[1<<16],s[MN+5][MN+5];
inline void R(int&x,int y){y>x?x=y:0;}
/*struct Bitset
{
    ull a,b;
    Bitset(){a=b=0;}
    Bitset(ull c,ull d):a(c),b(d){}
    void Mod(int y){y>=64?(b|=1ULL<<y-64):(a|=1ULL<<y);}
    Bitset operator & (const Bitset&c){return Bitset(a&c.a,b&c.b);}
    int Count(){return cnt[a&N]+cnt[a>>16&N]+cnt[a>>32&N]+cnt[a>>48&N]
                      +cnt[b&N]+cnt[b>>16&N]+cnt[b>>32&N]+cnt[b>>48&N];}
    Bitset operator << (int y){return y>=64?Bitset(0,a<<y-64):Bitset(a<<y,b<<y|(a>>64-y));}
};*/
bitset<105> lru[MN+5][MN+5],lrd[MN+5][MN+5],udl[MN+5][MN+5],udr[MN+5][MN+5],a[MN+5],b[MN+5];
inline int C(int u,int l,int d,int r){return s[d][r]-s[u-1][r]-s[d][l-1]+s[u-1][l-1];}
int main()
{
    for(int i=1;i<=N;++i) cnt[i]=cnt[i>>1]+(i&1);
    n=read();m=read();
    for(int i=1,k=0;i<=n;++i)for(int j=i;j<=n;++j)num[i][j]=++k;
    for(int i=1,k=0;i<=m;++i)for(int j=i;j<=m;++j)num2[i][j]=++k;
    for(int i=1;i<=n;++i) scanf("%s",st[i]+1);
    for(int i=1;i<=n;++i) for(int j=1;j<=m;++j)
    {
        if(st[i][j]=='o') a[i][j]=1,b[j][i]=1;
        s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(st[i][j]=='E');
    }
    for(int i=1;i<=m;++i) for(int j=1;j<=n;++j)
        for(int k=1;k<=i;++k)
        {
            if(C(1,k,n-j+1,m-(i-k))) lru[i][j][k]=1;
            if(C(j,k,n,m-(i-k)))     lrd[i][j][k]=1;
        }
    for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)
        for(int k=1;k<=i;++k)
        {
            if(C(k,1,n-(i-k),m-j+1)) udl[i][j][k]=1;
            if(C(k,j,n-(i-k),m))     udr[i][j][k]=1;
        }
    for(int i=1;i<=n;++i) for(int j=n;j>=i;--j)
        for(int k=1;k<=m;++k) for(int l=m;l>=k;--l)
        {
            int v=F(i,j,k,l);
            R(F(i+1,j,k,l),v+(a[i]&(lru[l-k+1][j-i+1]<<k-1)).count());
            R(F(i,j-1,k,l),v+(a[j]&(lrd[l-k+1][j-i+1]<<k-1)).count());
            R(F(i,j,k+1,l),v+(b[k]&(udl[j-i+1][l-k+1]<<i-1)).count());
            R(F(i,j,k,l-1),v+(b[l]&(udr[j-i+1][l-k+1]<<i-1)).count());
        }
    printf("%d\n",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int getsum(const vvi& sums,int t,int b,int l,int r)
{
	if(l>=r || t>=b) return 0;
	return sums[b][r]-sums[t][r]-sums[b][l]+sums[t][l];
}

void chmax(int& a,int b)
{
	a=max(a,b);
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		vs grid(h);
		rep(i,h) cin>>grid[i];

		int ci=-1,cj=-1;
		rep(i,h) rep(j,w) if(grid[i][j]=='E') ci=i,cj=j;

		vvi sums(h+1,vi(w+1));
		rep(i,h) rep(j,w)
			sums[i+1][j+1]=(grid[i][j]=='o')+sums[i+1][j]+sums[i][j+1]-sums[i][j];

		int T=h-1-ci,B=ci,L=w-1-cj,R=cj;

		int dp[T+1][B+1][L+1][R+1]={};
		rep(t,T+1) rep(b,B+1) rep(l,L+1) rep(r,R+1){
			if(t!=T && ci+t+1<h-b)
				chmax(dp[t+1][b][l][r],dp[t][b][l][r]+getsum(sums,ci+(t+1),ci+(t+1)+1,max(cj-r,l),min(cj+l+1,w-r)));
			if(b!=B && t<=ci-(b+1))
				chmax(dp[t][b+1][l][r],dp[t][b][l][r]+getsum(sums,ci-(b+1),ci-(b+1)+1,max(cj-r,l),min(cj+l+1,w-r)));
			if(l!=L && cj+l+1<w-r)
				chmax(dp[t][b][l+1][r],dp[t][b][l][r]+getsum(sums,max(ci-b,t),min(ci+t+1,h-b),cj+(l+1),cj+(l+1)+1));
			if(r!=R && l<=cj-(r+1))
				chmax(dp[t][b][l][r+1],dp[t][b][l][r]+getsum(sums,max(ci-b,t),min(ci+t+1,h-b),cj-(r+1),cj-(r+1)+1));
		}

		int res=0;
		rep(t,T+1) rep(b,B+1) rep(l,L+1) rep(r,R+1) chmax(res,dp[t][b][l][r]);
		cout<<res<<endl;
	}
}
