#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

typedef long long ll;
typedef pair<ll,ll> P;

ll tate[2002][2002];
ll yoko[2002][2002];
ll nana[2002][2002];
ll dp[2002][2002];
char mp[2002][2002];

void mod_add(ll &a, ll b) {
	a += b;
	a %= MOD;
}

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

	ll h, w;cin >> h >> w;
	REP(i, h) {
		REP(j, w) {
			cin >> mp[i][j];
		}
	}

	dp[0][0] = 1;
	tate[0][0] = 1;
	yoko[0][0] = 1;
	nana[0][0] = 1;
	REP(i, h) {
		REP(j, w) {
			if (mp[i][j] == '#') continue;
			if (i == 0 && j == 0) continue;

			if (i > 0) mod_add(dp[i][j], tate[i-1][j]);
			if (j > 0) mod_add(dp[i][j], yoko[i][j-1]);
			if (i > 0 && j > 0) mod_add(dp[i][j], nana[i-1][j-1]);

			tate[i][j] += dp[i][j];
			yoko[i][j] += dp[i][j];
			nana[i][j] += dp[i][j];

			if (i > 0) {
				mod_add(tate[i][j], tate[i-1][j]);
			}
			if (j > 0) {
				mod_add(yoko[i][j], yoko[i][j-1]);
			}
			if (i > 0 && j > 0) {
				mod_add(nana[i][j], nana[i-1][j-1]);
			}
		}
	}

	// SHOW2d(dp, h, w);

	cout << dp[h-1][w-1] << endl;

	return 0;
}

#include <bits/stdc++.h>
using  namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);   
#define ll                     long long 
#define endl                   "\n"
#define V                      vector<ll>
#define VT(A)                  vector<A>
#define P                      pair<ll, ll>
#define ST(A)                  set<A>
#define US(A)                  unordered_set<A>
#define M                      map<ll, ll>
#define MT(A,B)                 map<A,B>
#define UM(A,B)                unordered_map<A,B>
#define PQ(A)                  priority_queue<A>
#define HP(A)                  priority_queue<A, vector<int>, greater<A>>
#define F                      first
#define S                      second 
#define T                      top()
#define B                      back()
#define PU                     push
#define PO                     pop()
#define PB                     push_back 
#define POB                    pop_back 
#define EB                     emplace_back
#define MP                     make_pair
#define MOD                    1e9 + 7 
#define INF                    100000000000000003
#define IN(a)                  cin >> (a)
#define PE(a)                  cout << (a) << endl 
#define PS(a)                  cout << (a) << " " 
#define PSS(a,b)               cout << (a) << " " << (b) << endl;
#define MAX(a, b)              ((a) < (b) ? (b) : (a)) 
#define MIN(a, b)              ((a) > (b) ? (b) : (a)) 
#define ALL(v)                 (v).begin(), (v).end()
#define FOR(a, b, c, s)        for (ll (a) = (b); (a) < (c); (a)+=s)
#define FORL(a, b, c, s)       for (ll (a) = (b); (a) <= (c); (a)+=s)
#define FORR(a, b, c, s)       for (ll (a) = (b); (a) >= (c); (a)-=s)
#define FORA(i, a)             for(auto& (i) : (a))
#define N                      1e7+10

void init_code()
{
    fast;
    //seive();
}

void solve()
{
    // Jai Shree Ram
    ll h,w,x,y;
    cin >> h >> w >> x >> y;

    x--, y--;
    vector<string> s(h);
    FOR(i,0,h,1) IN(s[i]);

    ll res = -3;

    for(ll i=x; i<h && s[i][y] == '.'; i++) res++;
    for(ll i=x; i>=0 && s[i][y] == '.'; i--) res++;
    for(ll j=y; j<w && s[x][j] == '.'; j++) res++;
    for(ll j=y; j>=0 && s[x][j] == '.'; j--) res++;

    PE(res);
}

int main() {

    init_code();
    
    solve();
    
    return 0;
}