#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ull unsigned long long
#define mod 1000000007
#define pb push_back
const int N =2010;
int n,m,sti,stj,ll,rr,vis[N][N];
char g[N][N];
void bfs()
{
deque<pair<pair<int,int>,pair<int,int>>>q;
q.push_front({{sti,stj},{ll,rr}});
vis[sti][stj]=1;
while(!q.empty())
{
int i=q.front().first.first;
int j= q.front().first.second;
int l= q.front().second.first;
int r= q.front().second.second;
q.pop_front();
int k=l;
for(int x=j-1;x>0;x--)
{
if(k==0) break;
k--;
if(!vis[i][x] && g[i][x]!= '*')
{
q.push_back({{i,x},{k,r}});
vis[i][x]=1;
}
else break;
}
k=r;
for(int x=j+1;x<=m;x++)
{
if(k==0) break;
k--;
if(!vis[i][x] && g[i][x]!= '*')
{
q.push_back({{i,x},{l,k}});
vis[i][x]=1;
}
else break;
}
k=i-1;
while(k>0)
{
if(g[k][j]=='*' || vis[k][j]) break;
q.push_front({{k,j},{l,r}});
vis[k][j]=1;
k--;
}
k=i+1;
while(k<=n)
{
if(g[k][j]=='*' || vis[k][j]) break;
q.push_front({{k,j},{l,r}});
vis[k][j]=1;
k++;
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >>m >> sti >> stj >>ll >>rr;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
cin >> g[i][j];
}
bfs();
int cnt=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(vis[i][j])
cnt++;
}
}
cout << cnt;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZW5kbCAnXG4nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIG1vZCAxMDAwMDAwMDA3CiNkZWZpbmUgcGIgcHVzaF9iYWNrCmNvbnN0IGludCBOID0yMDEwOwppbnQgbixtLHN0aSxzdGosbGwscnIsdmlzW05dW05dOwpjaGFyIGdbTl1bTl07CnZvaWQgYmZzKCkKewogICAgZGVxdWU8cGFpcjxwYWlyPGludCxpbnQ+LHBhaXI8aW50LGludD4+PnE7CiAgICBxLnB1c2hfZnJvbnQoe3tzdGksc3RqfSx7bGwscnJ9fSk7CiAgICB2aXNbc3RpXVtzdGpdPTE7CiAgICB3aGlsZSghcS5lbXB0eSgpKQogICAgewogICAgICAgIGludCBpPXEuZnJvbnQoKS5maXJzdC5maXJzdDsKICAgICAgICBpbnQgaj0gcS5mcm9udCgpLmZpcnN0LnNlY29uZDsKICAgICAgICBpbnQgbD0gcS5mcm9udCgpLnNlY29uZC5maXJzdDsKICAgICAgICBpbnQgcj0gcS5mcm9udCgpLnNlY29uZC5zZWNvbmQ7CiAgICAgICAgcS5wb3BfZnJvbnQoKTsKICAgICAgICBpbnQgaz1sOwogICAgICAgIGZvcihpbnQgeD1qLTE7eD4wO3gtLSkKICAgICAgICB7CiAgICAgICAgICAgIGlmKGs9PTApIGJyZWFrOwogICAgICAgICAgICBrLS07CiAgICAgICAgICAgIGlmKCF2aXNbaV1beF0gJiYgZ1tpXVt4XSE9ICcqJykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcS5wdXNoX2JhY2soe3tpLHh9LHtrLHJ9fSk7CiAgICAgICAgICAgICAgICB2aXNbaV1beF09MTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGJyZWFrOwogICAgICAgIH0KICAgICAgICBrPXI7CiAgICAgICAgZm9yKGludCB4PWorMTt4PD1tO3grKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKGs9PTApIGJyZWFrOwogICAgICAgICAgICBrLS07CiAgICAgICAgICAgIGlmKCF2aXNbaV1beF0gJiYgZ1tpXVt4XSE9ICcqJykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcS5wdXNoX2JhY2soe3tpLHh9LHtsLGt9fSk7CiAgICAgICAgICAgICAgICB2aXNbaV1beF09MTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGJyZWFrOwogICAgICAgIH0KICAgICAgICBrPWktMTsKICAgICAgICB3aGlsZShrPjApCiAgICAgICAgewogICAgICAgICAgICBpZihnW2tdW2pdPT0nKicgfHwgdmlzW2tdW2pdKSBicmVhazsKICAgICAgICAgICAgcS5wdXNoX2Zyb250KHt7ayxqfSx7bCxyfX0pOwogICAgICAgICAgICB2aXNba11bal09MTsKICAgICAgICAgICAgay0tOwogICAgICAgIH0KICAgICAgICBrPWkrMTsKICAgICAgICB3aGlsZShrPD1uKQogICAgICAgIHsKICAgICAgICAgICAgaWYoZ1trXVtqXT09JyonIHx8IHZpc1trXVtqXSkgYnJlYWs7CiAgICAgICAgICAgIHEucHVzaF9mcm9udCh7e2ssan0se2wscn19KTsKICAgICAgICAgICAgdmlzW2tdW2pdPTE7CiAgICAgICAgICAgIGsrKzsKICAgICAgICB9CiAgICB9Cn0KaW50IG1haW4oKQp7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBjb3V0LnRpZSgwKTsKICAgIGNpbiA+PiBuID4+bSA+PiBzdGkgPj4gc3RqID4+bGwgID4+cnI7CiAgICBmb3IoaW50IGk9MTtpPD1uO2krKykKICAgIHsKICAgICAgICBmb3IoaW50IGo9MTtqPD1tO2orKykKICAgICAgICAgICAgY2luID4+IGdbaV1bal07CiAgICB9CiAgICBiZnMoKTsKICAgIGludCBjbnQ9MDsKICAgIGZvcihpbnQgaT0xO2k8PW47aSsrKQogICAgewogICAgICAgIGZvcihpbnQgaj0xO2o8PW07aisrKQogICAgICAgICAgIHsKICAgICAgICAgICAgIGlmKHZpc1tpXVtqXSkKICAgICAgICAgICAgICAgIGNudCsrOwogICAgICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgY250Owp9Cg==