#include <bits/stdc++.h>
using namespace std;
char board[2005][2005];
int vis[2005][2005];
int n, m;
int r, c;
int x, y;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
struct state {
  int rr, cc;
  int l, r;
  state(int a, int b, int aa, int bb) {
    rr = a;
    cc = b;
    l = aa;
    r = bb;
  }
};
inline bool bound(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
int main() {
  cin >> n >> m >> r >> c >> x >> y;
  r--;
  c--;
  for (int i = 0; i < n; i++) {
    cin >> board[i];
  }
  queue<state> q;
  q.push(state(r, c, x, y));
  int ans = 0;
  while (!q.empty()) {
    state &fr = q.front();
    if (vis[fr.rr][fr.cc]) {
      q.pop();
      continue;
    }
    int cr = fr.rr;
    int cc = fr.cc;
    int nr = cr;
    int upr = cr, dnr = cr;
    while (nr >= 0 && board[nr][cc] == '.' && !vis[nr][cc]) {
      vis[nr][cc] = 1;
      ans++;
      upr = nr;
      nr--;
    }
    nr = cr + 1;
    while (nr < n && board[nr][cc] == '.' && !vis[nr][cc]) {
      vis[nr][cc] = 1;
      ans++;
      dnr = nr;
      nr++;
    }
    char flagl = '*', flagr = '*';
    for (int i = upr; i <= dnr; i++) {
      if (cc - 1 >= 0 && fr.l > 0) {
        if (!(board[i][cc - 1] == flagl && !vis[i][cc - 1])) {
          flagl = board[i][cc - 1];
          if (flagl == '.') q.push(state(i, cc - 1, fr.l - 1, fr.r));
        }
      }
      if (cc + 1 < m && fr.r > 0) {
        if (!(board[i][cc + 1] == flagr && !vis[i][cc + 1])) {
          flagr = board[i][cc + 1];
          if (flagr == '.') q.push(state(i, cc + 1, fr.l, fr.r - 1));
        }
      }
    }
    q.pop();
    int pause = 0;
  }
  cout << ans;
  return 0;
}
