#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,m,sum1[110][110],sum2[110][110],a,b;
short ans,f[101][101][101][101];
char s[110];

void update(short &x,short y)
{
    if (y>x)
        x=y;
}

int main()
{
    scanf("%d%d",&n,&m);
    repu(i,1,n)
    {
        scanf("%s",s+1);
        repu(j,1,m)
        {
            if (s[j]=='E')
                a=i,b=j;
            sum1[i][j]=sum1[i][j-1]+(s[j]=='o');
            sum2[i][j]=sum2[i-1][j]+(s[j]=='o');
        }
    }
    repu(i,0,n-a)
        repu(j,0,a-1)
            repu(k,0,m-b)
                repu(l,0,b-1)
                {
                    update(ans,f[i][j][k][l]);
                    int x=max(b-l,k+1),y=min(b+k,m-l);
                    if (a+i+1+j<=n)
                        update(f[i+1][j][k][l],f[i][j][k][l]+sum1[a+i+1][y]-sum1[a+i+1][x-1]);
                    if (a-j-1-i>0)
                        update(f[i][j+1][k][l],f[i][j][k][l]+sum1[a-j-1][y]-sum1[a-j-1][x-1]);
                    x=max(a-j,i+1),y=min(a+i,n-j);
                    if (b+k+1+l<=m)
                        update(f[i][j][k+1][l],f[i][j][k][l]+sum2[y][b+k+1]-sum2[x-1][b+k+1]);
                    if (b-l-1-k>0)
                        update(f[i][j][k][l+1],f[i][j][k][l]+sum2[y][b-l-1]-sum2[x-1][b-l-1]);
                }
    printf("%d\n",ans);
    return 0;
}