#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

short col[101][101];

short row[101][101];

short  dp[101][101][101][101];

int main(){
    int n,m;
    cin >> n >> m;
    vector<string> s(n);
    rep(i,n)cin >> s[i];
    int ei,ej;
    rep(i,n){
        rep(j,m){
            if(s[i][j]=='E'){
                ei = i;
                ej = j;
            }else if(s[i][j]=='o'){
                col[i][j]++;
                row[i][j]++;
            }
        }
    }
    rep(i,n){
        rep(j,m){
            row[i][j+1] += row[i][j];
        }
    }
    rep(i,n){
        rep(j,m){
            col[i+1][j] += col[i][j];
        }
    }
    rep(d,n){
        if(ei+d>=n)break;
        rep(u,n){
            if(ei-u<0)break;
            if(d+u>=n)break;
            rep(l,m){
                if(ej+l>=m)break;
                rep(r,m){
                    if(ej-r<0)break;
                    if(l+r>=m)break;
                    int L = ej-r;
                    int R = ej+l;
                    int D = ei-u;
                    int U = ei+d;
                    
                    chmax(dp[d+1][u][l][r],dp[d][u][l][r]);
                    if(d>=D&&d<=U){
                        int LL = max(l,L);
                        int RR = min(m-1-r,R);
                        short cc = row[d][RR];
                        if(LL!=0)cc -= row[d][LL-1];
                        chmax(dp[d+1][u][l][r],(short)(dp[d][u][l][r]+cc));
                    }
                    chmax(dp[d][u+1][l][r],dp[d][u][l][r]);
                    if(n-1-u<=U&&n-1-u>=D){
                        int LL = max(l,L);
                        int RR = min(m-1-r,R);
                        short cc = row[n-1-u][RR];
                        if(LL!=0)cc -= row[n-1-u][LL-1];
                        chmax(dp[d][u+1][l][r],(short)(dp[d][u][l][r]+cc));
                    }
                    chmax(dp[d][u][l+1][r],dp[d][u][l][r]);
                    if(l>=L&&l<=R){
                        int DD = max(d,D);
                        int UU = min(n-1-u,U);
                        short cc = col[UU][l];
                        if(DD!=0)cc -= col[DD-1][l];
                        chmax(dp[d][u][l+1][r],(short)(dp[d][u][l][r]+cc));
                    }
                    chmax(dp[d][u][l][r+1],dp[d][u][l][r]);
                    if(m-1-r<=R&&m-1-r>=L){
                        int DD = max(d,D);
                        int UU = min(n-1-u,U);
                        short cc = col[UU][m-1-r];
                        if(DD!=0)cc -= col[DD-1][m-1-r];
                        
                        
                        chmax(dp[d][u][l][r+1],(short)(dp[d][u][l][r]+cc));
                    }
                }
            }
        }
    }
    short mx = 0;
    rep(d,n){
        rep(u,n){
            if(d+u>n)break;
            rep(l,m){
                rep(r,m){
                    if(l+r>m)break;
                    // cerr << d << " " << u << " " << l << " " << r << " " << dp[d][u][l][r] << endl;
                    chmax(mx,dp[d][u][l][r]);
                }
            }
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 201088