#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.pb({{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.pb({{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+PnE7CiAgICBxLnB1c2hfZnJvbnQoe3tzdGksc3RqfSx7bGwscnJ9fSk7CiAgICB2aXNbc3RpXVtzdGpdPTE7CiAgICB3aGlsZSghcS5lbXB0eSgpKQogICAgewogICAgICAgIGludCBpPXEuZnJvbnQoKS5maXJzdC5maXJzdDsKICAgICAgICBpbnQgaj0gcS5mcm9udCgpLmZpcnN0LnNlY29uZDsKICAgICAgICBpbnQgbD0gcS5mcm9udCgpLnNlY29uZC5maXJzdDsKICAgICAgICBpbnQgcj0gcS5mcm9udCgpLnNlY29uZC5zZWNvbmQ7CiAgICAgICAgcS5wb3BfZnJvbnQoKTsKICAgICAgICBpbnQgaz1sOwogICAgICAgIGZvcihpbnQgeD1qLTE7eD4wO3gtLSkKICAgICAgICB7CiAgICAgICAgICAgIGlmKGs9PTApIGJyZWFrOwogICAgICAgICAgICBrLS07CiAgICAgICAgICAgIGlmKCF2aXNbaV1beF0gJiYgZ1tpXVt4XSE9ICcqJykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgcS5wYih7e2kseH0se2sscn19KTsKICAgICAgICAgICAgICAgIHZpc1tpXVt4XT0xOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGs9cjsKICAgICAgICBmb3IoaW50IHg9aisxO3g8PW07eCsrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoaz09MCkgYnJlYWs7CiAgICAgICAgICAgIGstLTsKICAgICAgICAgICAgaWYoIXZpc1tpXVt4XSAmJiBnW2ldW3hdIT0gJyonKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBxLnBiKHt7aSx4fSx7bCxrfX0pOwogICAgICAgICAgICAgICAgdmlzW2ldW3hdPTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBicmVhazsKICAgICAgICB9CiAgICAgICAgaz1pLTE7CiAgICAgICAgd2hpbGUoaz4wKQogICAgICAgIHsKICAgICAgICAgICAgaWYoZ1trXVtqXT09JyonIHx8IHZpc1trXVtqXSkgYnJlYWs7CiAgICAgICAgICAgIHEucHVzaF9mcm9udCh7e2ssan0se2wscn19KTsKICAgICAgICAgICAgdmlzW2tdW2pdPTE7CiAgICAgICAgICAgIGstLTsKICAgICAgICB9CiAgICAgICAgaz1pKzE7CiAgICAgICAgd2hpbGUoazw9bikKICAgICAgICB7CiAgICAgICAgICAgIGlmKGdba11bal09PScqJyB8fCB2aXNba11bal0pIGJyZWFrOwogICAgICAgICAgICBxLnB1c2hfZnJvbnQoe3trLGp9LHtsLHJ9fSk7CiAgICAgICAgICAgIHZpc1trXVtqXT0xOwogICAgICAgICAgICBrKys7CiAgICAgICAgfQogICAgfQp9CmludCBtYWluKCkKewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOwogICAgY291dC50aWUoMCk7CiAgICBjaW4gPj4gbiA+Pm0gPj4gc3RpID4+IHN0aiA+PmxsICA+PnJyOwogICAgZm9yKGludCBpPTE7aTw9bjtpKyspCiAgICB7CiAgICAgICAgZm9yKGludCBqPTE7ajw9bTtqKyspCiAgICAgICAgICAgIGNpbiA+PiBnW2ldW2pdOwogICAgfQogICAgYmZzKCk7CiAgICBpbnQgY250PTA7CiAgICBmb3IoaW50IGk9MTtpPD1uO2krKykKICAgIHsKICAgICAgICBmb3IoaW50IGo9MTtqPD1tO2orKykKICAgICAgICAgICB7CiAgICAgICAgICAgICBpZih2aXNbaV1bal0pCiAgICAgICAgICAgICAgICBjbnQrKzsKICAgICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IGNudDsKfQo=