#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
bool seive[2005];
void SieveOfEratosthenes(ll n)
{ memset(seive, true, sizeof(seive)); for (ll p=2; p*p<=n; p++) if (seive[p] == true) for (ll i=p*p; i<=n; i += p) seive[i] = false; }
ll fastpow(ll a, ll p){ if(p==0) return 1; ll z = fastpow(a,p/2); z = (z*z); if(p%2) z = (z*a); return z; }
ll dx[]={1,-1,0,0};
ll dy[]={0,0,1,-1};
ll visited[2005][2005]={0};
ll val[2005][2005];
char a[2005][2005];
ll l1,r1;
ll x_total,y_total;
priority_queue <pair<ll,pair<ll,ll>>> pq;
int main()
{
// djikstra with 1 weight assigned to all the left moving edge(path) else all paths /edges have 0 weight
fast;//fast i/o
ll n,i,y_origin,x_origin;
cin>>y_total>>x_total;//coordinates of the total cell structure
cin>>y_origin>>x_origin;//coordintes of the orignal point
cin>>l1>>r1;
y_origin--;//co-ordinte substracted so that 0-cordinate system can be used;
x_origin--;
for(ll i=0;i<y_total;i++)
for(ll j=0;j<x_total;j++)
{
cin>>a[i][j]; //character array
val[i][j]=LLONG_MAX;//the shortest length to all paths to be infinity
}
pq.push(mp(0,mp(y_origin,x_origin)));//origin pushed to priority_queue
val[y_origin][x_origin]=0;
while(!pq.empty())
{
ll present_father_y=pq.top().se.fi;//present_coordinate
ll present_father_x=pq.top().se.se;//present_coordinate
ll present_father_val=-pq.top().fi;//present_value
pq.pop();
visited[present_father_y][present_father_x]=1;//array so that same co-ordinate is not visited
for(ll k=0;k<4;k++)
{
ll child_y=present_father_y+dy[k];
ll child_x=present_father_x+dx[k];
if(child_x<0 or child_x>=x_total or child_y<0 or child_y>=y_total)//check the bounds
continue;
if(a[child_y][child_x]=='*')
continue;
if(visited[child_y][child_x])
{
continue;
}
ll child_val=present_father_val+(dx[k]==-1);
if(child_val>l1)//if no of lefts is exceeded dont add it to queue(optimization)
continue;
if(val[child_y][child_x]>=child_val)
{
val[child_y][child_x]=child_val;
pq.push(mp(-child_val,mp(child_y,child_x)));
}
}
}
ll sum=0;
for(ll i=0;i<y_total;i++)
for(ll j=0;j<x_total;j++)
{
if(visited[i][j]==0)
continue;
if(val[i][j]<=l1 and val[i][j]-x_origin+j<=r1)//final-check
{
sum++;
}
}
cout<<sum;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlPGxpbWl0cy5oPgojaW5jbHVkZTxzdGRpby5oPgojaW5jbHVkZTxjc3RyaW5nPgojaW5jbHVkZTxzdHJpbmc+CnVzaW5nIG5hbWVzcGFjZSAgc3RkOwp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiBsb25nIGRvdWJsZSBsZDsKI2RlZmluZSBmYXN0IGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpO2Npbi50aWUoMCk7Y291dC50aWUoMCkKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBzeihhKSBhLnNpemUoKQojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgc2Ugc2Vjb25kCiNkZWZpbmUgcnN6KGEsbikgYS5yZXNpemUobikKI2RlZmluZSB0ZXN0KHQpIGxsIHQ7Y2luPj50O3doaWxlKHQtLSkKI2RlZmluZSBmb3JuKGksZSkgZm9yKGludCBpID0gMDsgaSA8IGU7IGkrKykKI2RlZmluZSBmb3JzbihpLHMsZSkgZm9yKGludCBpID0gczsgaSA8IGU7IGkrKykKI2RlZmluZSByZm9ybihpLHMpIGZvcihpbnQgaSA9IHM7IGkgPj0gMDsgaS0tKQojZGVmaW5lIHJmb3JzbihpLHMsZSkgZm9yKGludCBpID0gczsgaSA+PSBlOyBpLS0pCiNkZWZpbmUgZmlsbHYoYSxrKSBtZW1zZXQoYSx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IG5vdCB2aXNpdGVkCiAgICAgICAgZm9yKGxsIGs9MDtrPDQ7aysrKQogICAgICAgIHsKICAgICAgICAgICAgbGwgY2hpbGRfeT1wcmVzZW50X2ZhdGhlcl95K2R5W2tdOwogICAgICAgICAgICBsbCBjaGlsZF94PXByZXNlbnRfZmF0aGVyX3grZHhba107CiAgICAgICAgICAgIGlmKGNoaWxkX3g8MCBvciBjaGlsZF94Pj14X3RvdGFsIG9yIGNoaWxkX3k8MCBvciBjaGlsZF95Pj15X3RvdGFsKS8vY2hlY2sgdGhlIGJvdW5kcwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIGlmKGFbY2hpbGRfeV1bY2hpbGRfeF09PScqJykKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBpZih2aXNpdGVkW2NoaWxkX3ldW2NoaWxkX3hdKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsbCBjaGlsZF92YWw9cHJlc2VudF9mYXRoZXJfdmFsKyhkeFtrXT09LTEpOwogICAgICAgICAgICBpZihjaGlsZF92YWw+bDEpLy9pZiBubyBvZiBsZWZ0cyBpcyBleGNlZWRlZCBkb250IGFkZCBpdCB0byBxdWV1ZShvcHRpbWl6YXRpb24pCiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgaWYodmFsW2NoaWxkX3ldW2NoaWxkX3hdPj1jaGlsZF92YWwpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHZhbFtjaGlsZF95XVtjaGlsZF94XT1jaGlsZF92YWw7CiAgICAgICAgICAgICAgICBwcS5wdXNoKG1wKC1jaGlsZF92YWwsbXAoY2hpbGRfeSxjaGlsZF94KSkpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgbGwgc3VtPTA7CiAgICBmb3IobGwgaT0wO2k8eV90b3RhbDtpKyspCiAgICAgICAgZm9yKGxsIGo9MDtqPHhfdG90YWw7aisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYodmlzaXRlZFtpXVtqXT09MCkKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBpZih2YWxbaV1bal08PWwxIGFuZCB2YWxbaV1bal0teF9vcmlnaW4rajw9cjEpLy9maW5hbC1jaGVjawogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBzdW0rKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIGNvdXQ8PHN1bTsKCgoKfQo=