#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
struct node {
  int x, y, l, r;
};
bool operator<(const node &a, const node &b) {
  if (a.l + a.r != b.l + b.r) return a.l + a.r < b.l + b.r;
  return min(a.l, a.r) > min(b.l, b.r);
}
priority_queue<node> P;
bool vis[maxn][maxn];
char t[maxn][maxn];
int d[4][2] = {{-1, 0}, {0, 1}, {0, -1}, {1, 0}};
int main() {
  int n, m, st, en, L, R, ans = 1;
  scanf("%d%d%d%d%d%d", &n, &m, &st, &en, &L, &R);
  for (int i = 1; i <= n; i++) scanf("%s", t[i] + 1);
  node e;
  e.x = st;
  e.y = en;
  e.l = L;
  e.r = R;
  vis[st][en] = 1;
  P.push(e);
  while (!P.empty()) {
    e = P.top();
    P.pop();
    for (int i = 0; i < 4; i++) {
      int xx = e.x + d[i][0], yy = e.y + d[i][1];
      if (xx < 1 || xx > n || yy < 1 || yy > m || vis[xx][yy] ||
          t[xx][yy] == '*')
        continue;
      if (i == 1 && e.r >= 1)
        P.push(node{xx, yy, e.l, e.r - 1}), ans++, vis[xx][yy] = 1;
      else if (i == 2 && e.l >= 1)
        P.push(node{xx, yy, e.l - 1, e.r}), ans++, vis[xx][yy] = 1;
      else if (i == 0 || i == 3)
        P.push(node{xx, yy, e.l, e.r}), ans++, vis[xx][yy] = 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
