#include<bits/stdc++.h>
#include <set>
#include <stack>

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;
constexpr int mo2 = 998244353;
vector<pair<int,int>> d = {{-1,0},{0,-1},{1,0},{0,1}};
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int h,w,x,y;
    cin>>h>>w>>y>>x;
    x--;y--;
    vector<string> f(h);
    for(auto & a :f)cin>>a;
    int count = 0;
    for(auto [dy,dx] : d){
        int toy = y + dy;
        int tox = x + dx;
        while(true){
            if(toy >= h or toy < 0 or tox >= w or tox < 0 or f[toy][tox] == '#')break;
            count++;
            toy += dy;
            tox += dx;
        }
        
    }
    count++;
    cout << count << endl;
    return 0;
    
}
//Making love with his ego Ziggy sucked up into his mind
#include<bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define ff first
#define ss second
#define ter(x) cerr << #x << " = " << x << endl
typedef long long ll;
typedef pair<ll,ll> ii;
const int N=2e6;
int val[N],col[N];
int n,m;
char s[40];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%s",s);
		int pw=1;
		int here=0;
		for(int j=m-1;j>=0;j--){
			if(s[j]=='1')
				here|=pw;
			pw<<=1;
		}
		val[i]=here;
	}
	col[0]=1;
	int w=1;
	for(int i=1;i<n;i++){
		if((__builtin_popcount(val[0]^val[i]))%2==0)
			val[i]=1,w++;
	}
	int b=n-w;
	//ter(b);
	//ter(w);
	cout<<1LL*w*b<<endl;

	return 0;
}
