#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void chmax(int &x, int v) { if (x < v) x = v; }

int H, W;
int EX, EY;
char A[100][100];
int tate[100][100];
int yoko[100][100];
vector<vector<vector<vector<int> > > > dp;
inline int f_tate(int x, int l, int r) {
  l = max(l, 0);
  r = min(r, H-1);
  if (x<0||x>=W||l>r) return 0;
  return tate[x][r]-(l>0?tate[x][l-1]:0);
}
inline int f_yoko(int y, int l, int r) {
  l = max(l, 0);
  r = min(r, W-1);
  if (y<0||y>=H||l>r) return 0;
  return yoko[r][y]-(l>0?yoko[l-1][y]:0);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W;
  rep(i, H) rep(j, W) cin >> A[j][i];
  rep(x, W) rep(y, H) if (A[x][y] == 'E') EX = x, EY = y;
  rep(x, W) rep(y, H) tate[x][y] = yoko[x][y] = A[x][y] == 'o';
  rep(x, W-1) rep(y, H) yoko[x+1][y] += yoko[x][y];
  rep(x, W) rep(y, H-1) tate[x][y+1] += tate[x][y];

  dp.resize(W+1);
  rep(l, W+1) {
    dp[l].resize(W+1-l);
    rep(r, W+1-l) {
      dp[l][r].resize(H+1);
      rep(u, H+1) dp[l][r][u].resize(H+1-u, -INF);
    }
  }
  dp[0][0][0][0] = 0;
  rep(l, W) {
    rep(r, W-l) {
      rep(u, H) {
        rep(d, H-u) {
          if (dp[l][r][u][d] == -INF) continue;
          chmax(dp[l+1][r][u][d], dp[l][r][u][d] + ((EX-(l+1)<r)?0:f_tate(EX-(l+1), max(EY-u, d), min(EY+d, H-1-u))));
          chmax(dp[l][r+1][u][d], dp[l][r][u][d] + ((EX+(r+1)>=W-l)?0:f_tate(EX+(r+1), max(EY-u, d), min(EY+d, H-1-u))));
          chmax(dp[l][r][u+1][d], dp[l][r][u][d] + ((EY-(u+1)<d)?0:f_yoko(EY-(u+1), max(EX-l, r), min(EX+r, W-1-l))));
          chmax(dp[l][r][u][d+1], dp[l][r][u][d] + ((EY+(d+1)>=H-u)?0:f_yoko(EY+(d+1), max(EX-l, r), min(EX+r, W-1-l))));
        }
      }
    }
  }
  int m = 0;
  rep(l, W+1) rep(r, W+1-l) rep(u, H+1) rep(d, H+1-u) chmax(m, dp[l][r][u][d]);
  cout << m << "\n";
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int N=110;

int h,w,px,py,f[N][N][N][N],col[N][N],row[N][N];
bool mp[N][N];

void Init()
{
	scanf("%d%d",&h,&w);
	for (int i=1;i<=h;++i)
		for (int j=1;j<=w;++j)
		{
			char ch=getchar();
			while (ch!='o' && ch!='.' && ch!='E') ch=getchar();
			if (ch=='E') px=i,py=j;
			if (ch=='o') mp[i][j]=1;
			else mp[i][j]=0;
		}
}

int Col(int r,int l,int x)
{
	if (l>r) return 0;
	return col[r][x]-col[l][x];
}

int Row(int r,int l,int x)
{
	if (l>r) return 0;
	return row[x][r]-row[x][l];
}

void Solve()
{
	
	for (int i=1;i<=h;++i)
		for (int j=1;j<=w;++j)
		{
			col[i][j]=col[i-1][j]+mp[i][j];
			row[i][j]=row[i][j-1]+mp[i][j];
		}
	int ans=0;
	for (int a=px;a>0;--a)
		for (int b=px;b<=h;++b)
			for (int c=py;c>0;--c)
				for (int d=py;d<=w;++d) f[a][b][c][d]=-1e9;
	f[px][px][py][py]=0;
	for (int a=px;a>0;--a)
		for (int b=px;b<=h;++b)
			for (int c=py;c>0;--c)
				for (int d=py;d<=w;++d)
				{
					if (a>1 && a-1>b-px) 
						f[a-1][b][c][d]=max(f[a-1][b][c][d],f[a][b][c][d]+Row(min(w-(py-c),d),max(c-1,d-py),a-1));
					if (b<h && h-b>px-a) 
						f[a][b+1][c][d]=max(f[a][b+1][c][d],f[a][b][c][d]+Row(min(w-(py-c),d),max(c-1,d-py),b+1));
					if (c>1 && c-1>d-py) 
						f[a][b][c-1][d]=max(f[a][b][c-1][d],f[a][b][c][d]+Col(min(h-(px-a),b),max(a-1,b-px),c-1));
					if (d<w && w-d>py-c) 
						f[a][b][c][d+1]=max(f[a][b][c][d+1],f[a][b][c][d]+Col(min(h-(px-a),b),max(a-1,b-px),d+1));
					ans=max(ans,f[a][b][c][d]);
				}
	
	printf("%d\n",ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}