/* ***************************************
Author        :Scau.ion
Created Time  :2016/09/06 23:24:11 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=110;

int g[maxn][maxn],dp[maxn][maxn][maxn][maxn],sum[maxn][maxn];

int main()
{
	int n,m,x,y;
    scanf("%d%d",&n,&m);
    for (int j=1;j<=n;++j)
    {
        char s[maxn];
        scanf("%s",s+1);
        for (int k=1;k<=m;++k)
        {
            if (s[k]=='o') g[j][k]=1;
            else if (s[k]=='E')
            {
                x=j;
                y=k;
            }
            sum[j][k]=g[j][k]+sum[j-1][k]+sum[j][k-1]-sum[j-1][k-1];
        }
    }
    int x1=x-1,x2=n-x,y1=y-1,y2=m-y;
    int ans=0;
    for (int up=0;up<=x1;++up)
    {
        for (int down=0;down<=x2;++down)
        {
            for (int left=0;left<=y1;++left)
            {
                for (int right=0;right<=y2;++right)
                {
                    int upline=max(x-up,down+1);
                    int downline=min(x+down,n-up);
                    int leftline=max(y-left,right+1);
                    int rightline=min(y+right,m-left);
                    if (upline>downline||leftline>rightline) continue;
                    ans=max(ans,dp[up][down][left][right]);
                    //if (dp[up][down][left][right]) cout<<upline<<" "<<downline<<" "<<leftline<<" "<<rightline<<endl;
                    //if (dp[up][down][left][right]) cout<<up<<" "<<down<<" "<<left<<" "<<right<<" --> "<<dp[up][down][left][right]<<endl;
                    if (up+down<x1)
                    {
                        int add=sum[x-up-1][rightline]-sum[x-up-1][leftline-1]-sum[x-up-2][rightline]+sum[x-up-2][leftline-1];
                        dp[up+1][down][left][right]=max(dp[up+1][down][left][right],dp[up][down][left][right]+add);
                        //cout<<"1  "<<add<<endl;
                    }
                    if (down+up<x2)
                    {
                        int add=sum[x+down+1][rightline]-sum[x+down+1][leftline-1]-sum[x+down][rightline]+sum[x+down][leftline-1];
                        dp[up][down+1][left][right]=max(dp[up][down+1][left][right],dp[up][down][left][right]+add);
                        //cout<<"2  "<<add<<endl;
                    }
                    if (left+right<y1)
                    {
                        int add=sum[downline][y-left-1]-sum[upline-1][y-left-1]-sum[downline][y-left-2]+sum[upline-1][y-left-2];
                        dp[up][down][left+1][right]=max(dp[up][down][left+1][right],dp[up][down][left][right]+add);
                        //cout<<"3  "<<add<<endl;
                    }
                    if (right+left<y2)
                    {
                        int add=sum[downline][y+right+1]-sum[upline-1][y+right+1]-sum[downline][y+right]+sum[upline-1][y+right];
                        dp[up][down][left][right+1]=max(dp[up][down][left][right+1],dp[up][down][left][right]+add);
                        //cout<<"4  "<<add<<endl;
                    }
                }
            }
        }
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 73088