#include <bits/stdc++.h>
using namespace std;
int n, m;
int x, y;
int ln, rn;
const int maxn = 2336;
char maze[maxn][maxn];
bool vis[maxn][maxn];
struct node {
  int x, y;
  int l, r;
  node(int _x, int _y, int _l, int _r) { x = _x, y = _y, l = _l, r = _r; }
};
bool check(int x, int y) { return x >= 1 && x <= n && y >= 1 && y <= m; }
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int LL[maxn][maxn], RR[maxn][maxn];
int ans;
void bfs(int sx, int sy) {
  queue<node> q;
  q.push(node(sx, sy, ln, rn));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      LL[i][j] = RR[i][j] = -1;
    }
  }
  while (!q.empty()) {
    node rt = q.front();
    q.pop();
    if (!vis[rt.x][rt.y]) {
      ans++;
      vis[rt.x][rt.y] = 1;
    }
    for (int i = 0; i < 4; i++) {
      int dx = rt.x + dir[i][0];
      int dy = rt.y + dir[i][1];
      int ll = rt.l;
      int rr = rt.r;
      if (i == 1) --ll;
      if (i == 0) --rr;
      if (check(dx, dy) && maze[dx][dy] == '.' && ll >= 0 && rr >= 0 &&
          (ll > LL[dx][dy] || rr > RR[dx][dy])) {
        q.push(node(dx, dy, ll, rr));
        LL[dx][dy] = ll;
        RR[dx][dy] = rr;
      }
    }
  }
}
int main() {
  ans = 0;
  cin >> n >> m >> x >> y >> ln >> rn;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> maze[i][j];
    }
  }
  bfs(x, y);
  cout << ans << endl;
  return 0;
}
