#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

const int SZ = 2010;
class UF {
public:
	int P[SZ + 1];
	UF() : P() {
		rep1(i, SZ) P[i] = -1;
	}
	int find(int A) {
		if (P[A] < 0) return A;
		return P[A] = find(P[A]);
	}
	bool unite(int A, int B) {
		int a = find(A);
		int b = find(B);
		if (a == b) return false;
		if (P[a] > P[b]) swap(a, b);
		P[a] += P[b];
		P[b] = a;
		return true;
	}

} uf;

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


	int H, W;
	cin >> H >> W;

	uf.unite(1, 1001);
	uf.unite(1, W + 1000);
	uf.unite(H, 1001);
	uf.unite(H, W + 1000);

	rep1(i, H) {
		string S;
		cin >> S;
		rep(j, W) {
			if (S[j] == '#') {
				uf.unite(i, j + 1001);
			}
		}
	}

	int kotae = 1000;

	unordered_set<int> ST;
	rep1(i, H) {
		ST.insert(uf.find(i));
	}
	kotae = ST.size() - 1;
	ST.clear();
	rep1(j, W) {
		ST.insert(uf.find(j + 1000));
	}
	chmin(kotae, int(ST.size()) - 1);

	co(kotae);

	Would you please return 0;
}
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for(ll i = (ll)(m); i < (ll)(n); i++)
#define rep_inv(i, n, m) for(ll i = (ll)(n); i > (ll)(m); i--)

int main(){
  ll H, W, X, Y;
  cin >> H >> W >> X >> Y;

  vvc F(H, vc(W));
  string S;

  rep(i, H){
    cin >> S;

    rep(j, W) F[i][j] = S[j];
  }

  ll ans = 1;

  X--;
  Y--;

  rep2(i, 1, H){
    if(X - i < 0)
      break;
    if(F[X - i][Y] == '#')
      break;

    ans++;
  }

  rep2(i, 1, H){
    if(X + i >= H)
      break;
    if(F[X + i][Y] == '#')
      break;

    ans++;
  }

  rep2(i, 1, W){
    if(Y - i < 0)
      break;
    if(F[X][Y - i] == '#')
      break;

    ans++;
  }

  rep2(i, 1, W){
    if(Y + i >= W)
      break;
    if(F[X][Y + i] == '#')
      break;

    ans++;
  }

  cout << ans << "\n";
  
  return 0;
}
