#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
short line[103][103],list[103][103],f[103][103][103][103],n,m,op,sx,sy;
char s[103][103];
inline short min(short a,short b){
	if(a<b) return a;
	return b;
}
inline short max(short a,short b){
	if(a>b) return a;
	return b;
}
int main(){
    cin>>n>>m;
    for(short i=1;i<=n;i++){
    	cin>>(s[i]+1);
    }
    for(short i=1;i<=n;i++){
    	for(short j=1;j<=m;j++){
        	line[i][j]=line[i][j-1]+(s[i][j]=='o');
        	list[i][j]=list[i-1][j]+(s[i][j]=='o');
        	if(s[i][j]=='E'){
        		sx=i,sy=j;
			}
    	}
	}
    for(short i=sx;i;i--){
    	for(short j=sy;j;j--){
    		for(short k=sx;k<=n;k++){
    			for(short p=sy;p<=m;p++){
        			if(1<i&&k+1<sx+i){
        				f[i-1][j][k][p]=max(f[i-1][j][k][p],f[i][j][k][p]+line[i-1][min(p,m-sy+j)]-line[i-1][max(j-1,p-sy)]);
						op=max(op,f[i-1][j][k][p]);
					}
        			if(k<n&&sx+k<n+i){
        				f[i][j][k+1][p]=max(f[i][j][k+1][p],f[i][j][k][p]+line[k+1][min(p,m-sy+j)]-line[k+1][max(j-1,p-sy)]);
						op=max(op,f[i][j][k+1][p]);
					}
        			if(1<j&&p+1<sy+j){
        				f[i][j-1][k][p]=max(f[i][j-1][k][p],f[i][j][k][p]+list[min(k,n-sx+i)][j-1]-list[max(i-1,k-sx)][j-1]);
						op=max(op,f[i][j-1][k][p]);
					}
        			if(p<m&&sy+p<m+j){
        				f[i][j][k][p+1]=max(f[i][j][k][p+1],f[i][j][k][p]+list[min(k,n-sx+i)][p+1]-list[max(i-1,k-sx)][p+1]);
						op=max(op,f[i][j][k][p+1]);
					}
    			}
			}
		}
	}
    cout<<op<<endl;
    return 0;
}