#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long MOD = 1e9 + 7;
long long n, m, r, c, x, y;
bool vis[2005][2005];
char arr[2005][2005];
void bfs() {
  deque<pair<pair<long long, long long>, pair<long long, long long> > > q;
  q.push_front({{r, c}, {x, y}});
  while (!q.empty()) {
    r = q.front().first.first;
    c = q.front().first.second;
    x = q.front().second.first;
    y = q.front().second.second;
    q.pop_front();
    if (vis[r][c]) continue;
    vis[r][c] = 1;
    if (r - 1 > 0 && arr[r - 1][c] != '*' && !vis[r - 1][c])
      q.push_front({{r - 1, c}, {x, y}});
    if (r + 1 <= n && arr[r + 1][c] != '*' && !vis[r + 1][c])
      q.push_front({{r + 1, c}, {x, y}});
    if (x > 0 && c - 1 > 0 && arr[r][c - 1] != '*' && !vis[r][c - 1])
      q.push_back({{r, c - 1}, {x - 1, y}});
    if (y > 0 && c + 1 <= m && arr[r][c + 1] != '*' && !vis[r][c + 1])
      q.push_back({{r, c + 1}, {x, y - 1}});
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> r >> c >> x >> y;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) cin >> arr[i][j];
  long long ans = 0;
  bfs();
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) ans += vis[i][j];
  cout << ans;
}
