#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 105;
typedef v(string) vs;

int dp[MX][MX];

int main() {
  int h,w;
  scanf("%d%d",&h,&w);
  vs s(h);
  cin>>s;
  int si = 0, sj = 0;
  rep(i,h)rep(j,w) if (s[i][j] == 'E') si = i, sj = j;
  int ti = h-si, tj = w-sj;
  ++si; ++sj;
  if (si > ti) {
    swap(si,ti);
    reverse(rng(s));
  }
  if (sj > tj) {
    swap(sj,tj);
    rep(i,h) reverse(rng(s[i]));
  }

  vvi imos(h+1,vi(w+1));
  rep(i,h)rep(j,w) imos[i+1][j+1] = s[i][j]=='o';
  rep(i,h)rep(j,w+1) imos[i+1][j] += imos[i][j];
  rep(i,h+1)rep(j,w) imos[i][j+1] += imos[i][j];
  auto sum = [&](int li, int lj, int ri, int rj) {
    assert(0<=li && li<=ri && ri<=h); assert(0<=lj && lj<=rj && rj<=w);
    return imos[ri][rj] - imos[li][rj] - imos[ri][lj] + imos[li][lj];
  };

  int ans = 0;
  rep(ai,si)rep(aj,sj) {
    int bi = ai+ti, bj = aj+tj;
    if (bi > h || bj > w) continue;
    int now = sum(ai,aj,ai+si,aj+sj);
    srep(i,ai+si-1,bi)srep(j,aj+sj-1,bj) dp[i][j] = now;
    srep(i,ai+si-1,bi)srep(j,aj+sj-1,bj) {
      if (i+1 < bi) maxs(dp[i+1][j], dp[i][j]+sum(i+1,j-sj+1,i+2,j+1));
      if (j+1 < bj) maxs(dp[i][j+1], dp[i][j]+sum(i-si+1,j+1,i+1,j+2));
    }
    now = dp[bi-1][bj-1];
    maxs(ans, now);
  }

  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 384