#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
const int MAXN = 2005;
const int INF = 500005;
int n, m, r, c, x, y;
char grid[MAXN][MAXN];
bool vis[MAXN][MAXN];
using namespace std;
struct node {
  int l, r, nr, nc;
  node(int a, int b, int c, int d) {
    l = a;
    r = b;
    nr = c;
    nc = d;
  }
};
int main() {
  int ans = 0;
  std::ios::sync_with_stdio(false);
  cin >> n >> m >> r >> c >> x >> y;
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> grid[i][j];
    }
  }
  deque<node> q;
  q.push_front(node(0, 0, r, c));
  vis[r][c] = 1;
  while (!q.empty()) {
    node a = q.front();
    q.pop_front();
    for (int i = 1; i <= n; i++) {
      if (a.nr + i > n || grid[a.nr + i][a.nc] == '*' ||
          vis[a.nr + i][a.nc] == 1)
        break;
      else {
        q.push_front(node(a.l, a.r, a.nr + i, a.nc));
        vis[a.nr + i][a.nc] = 1;
      }
    }
    for (int i = -1; i >= -n; i--) {
      if (a.nr + i < 1 || grid[a.nr + i][a.nc] == '*' ||
          vis[a.nr + i][a.nc] == 1)
        break;
      else {
        q.push_front(node(a.l, a.r, a.nr + i, a.nc));
        vis[a.nr + i][a.nc] = 1;
      }
    }
    if (a.nc + 1 <= m && grid[a.nr][a.nc + 1] == '.' && a.r + 1 <= y &&
        !vis[a.nr][a.nc + 1]) {
      q.push_back(node(a.l, a.r + 1, a.nr, a.nc + 1));
      vis[a.nr][a.nc + 1] = 1;
    }
    if (a.nc - 1 >= 1 && grid[a.nr][a.nc - 1] == '.' && a.l + 1 <= x &&
        !vis[a.nr][a.nc - 1]) {
      q.push_back(node(a.l + 1, a.r, a.nr, a.nc - 1));
      vis[a.nr][a.nc - 1] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (vis[i][j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
