//#define MYDEBUG
#include <bits/stdc++.h>

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
typedef std::complex<int> P;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

const int MAX_N = 1 << 17;
const int LAZY_INIT = -1;
const int VAL_INIT = INT_MAX;
int N = 1;
int mini[MAX_N*2], lazy[MAX_N*2];

void init(int n_){
	while(N < n_){
		N *= 2;
	}
	for(int i = 0; i < N*2 - 1; ++i){
		lazy[i] = LAZY_INIT;
		mini[i] = VAL_INIT;
	}
}

void setLazy(int k, int v){
	lazy[k] = v;
	mini[k] = v;
}

void push(int k){
	if(lazy[k] == LAZY_INIT){
		return;
	}
	setLazy(k*2+1, lazy[k]);
	setLazy(k*2+2, lazy[k]);
	lazy[k] = LAZY_INIT;
}

void fix(int k){
	mini[k] = min(mini[k*2+1], mini[k*2+2]);
}

void fill(int qL, int qR, int val, int k=0, int nL=0, int nR=N){
	if(nR<=qL || qR<=nL){
		return;
	}
	if(qL<=nL && nR<=qR){
		setLazy(k, val);
		return;
	}
	push(k);
	int nM = (nL+nR)/2;
	fill(qL, qR, val, k*2+1, nL, nM);
	fill(qL, qR, val, k*2+2, nM, nR);
	fix(k);
}

int minimum(int qL, int qR, int k=0, int nL=0, int nR=N){
	if(qR<=nL || nR <=qL){
		return VAL_INIT;
	}
	if(qL<=nL && nR<=qR){
		return mini[k];
	}
	push(k);
	int nM = (nL+nR)/2;
	int vl = minimum(qL, qR, k*2+1, nL, nM);
	int vr = minimum(qL, qR, k*2+2, nM, nR);
	return min(vl, vr);
}

void print(){
	cout << "mini: ";
	rep(i, 0, N-1+N){
		cout << mini[i] << ",";
	}
	cout << endl;
	cout << "lazy: ";
	rep(i, 0, N-1+N){
		cout << lazy[i] << ",";
	}
	cout << endl;
}

int n, q;
void solve() {
	ifcin("/storage/emulated/0/AppProjects/AtCoder/jni/in.txt");
	cin >> n >> q;
	init(n);
	rep(query_index, 0, q){
		int com;
		cin >> com;
		if(com==0){
			int s,t,x;
			cin >> s >> t >> x;
			//print();
			fill(s, t+1, x);
			//dbp4(N, s,t,x);
			//print();
			//cout << endl;
		}else{
			int i;
			cin >> i;
			cout << minimum(i, i+1) << endl;
		}
	}
}

int main() {
	solve();
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n, m;
int x, y;

int a[110][110];

char buf[110];
void in(){
	read(n, m);
	for(int i=1; i<=n; ++i){
		scanf("%s", buf+1);
		for(int j=1; j<=m; ++j){
			a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
			if(buf[j] == 'o'){
				++a[i][j];
			} else if(buf[j] == 'E'){
				x=i; y=j;
			}
		}
	}
}

int dp[102][102][102][102];

int rect(int L1, int R1, int D1, int U1, int L2, int R2, int D2, int U2){
	int L=max(L1, L2);
	int R=min(R1, R2);
	int D=max(D1, D2);
	int U=min(U1, U2);
	if(L>R || D>U) return 0;
	if(0) printf("%d %d %d %d\n", L, R, D, U);
	return a[R][U]-a[L-1][U]-a[R][D-1]+a[L-1][D-1];
}

int main()
{
	in();
	for(int w=1; w<=n; ++w){
		for(int h=1; h<=m; ++h){
			for(int l=1; l+w-1<=n; ++l){
				int r=l+w-1;
				if(x<l || r<x) continue;
				for(int d=1; d+h-1<=m; ++d){
					int u=d+h-1;
					if(y<d || u<y) continue;
					int me=dp[l][r][d][u];
					auto f = [&](int A, int B, int C, int D){
						int I=l+A;
						int J=r+B;
						int K=d+C;
						int L=u+D;
						int nv = rect(1+(r-x), n-(x-l), 1+(u-y), m-(y-d),
							(A||B)?(A?I:J):(I),
							(A||B)?(A?I:J):(J),
							(C||D)?(C?K:L):(K),
							(C||D)?(C?K:L):(L)
						);
						int& T=dp[I][J][K][L];
						if(T < me+nv){
							if(0) printf("upd from %d-%d, %d-%d to df %d %d %d %d : %d+%d = %d\n",
								l,r,d,u, A,B,C,D, me, nv, me+nv);
						}
						T=max(T, me+nv);
					};
					if(1 < l) f(-1, 0, 0, 0);
					if(r < n) f(0, 1, 0, 0);
					if(1 < d) f(0, 0, -1, 0);
					if(u < m) f(0, 0, 0, 1);
				}
			}
		}
	}
	printf("%d\n", dp[1][n][1][m]);
	return 0;
}
