#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int H, W, X, Y;
	cin >> H >> W >> X >> Y;

	string S[100];
	rep(i, H) cin >> S[i];

	X--;
	Y--;
	int kotae = 1;
	for (int i = X + 1; i < H; i++) {
		if (S[i][Y] == '#') break;
		else kotae++;
	}
	for (int i = X - 1; i >= 0; i--) {
		if (S[i][Y] == '#') break;
		else kotae++;
	}
	for (int i = Y + 1; i < W; i++) {
		if (S[X][i] == '#') break;
		else kotae++;
	}
	for (int i = Y - 1; i >= 0; i--) {
		if (S[X][i] == '#') break;
		else kotae++;
	}

	co(kotae);

	Would you please return 0;
}
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans;

	ans = min(a, b);
	ans = min(ans, c);
	ans = min(ans, d);

	cout << ans << endl;
}

