#include <bits/stdc++.h>
using namespace std;
const int maxn = 2003;
char mat[maxn][maxn];
bool visite1[maxn][maxn];
bool visite2[maxn][maxn];
const int moves[][4] = {{0, 0, -1, 1}, {1, -1, 0, 0}};
struct edge {
  int x, y, sx, dx;
  bool operator<(const edge& b) const { return sx < b.sx; }
  bool operator>(const edge& b) const { return dx < b.dx; }
};
int solve(int r, int c, int startSX, int startDX) {
  auto cmp1 = [](const edge& a, const edge& b) { return a.sx < b.sx; };
  auto cmp2 = [](const edge& a, const edge& b) { return a.dx < b.dx; };
  priority_queue<edge, vector<edge>, less<edge>> pq1;
  priority_queue<edge, vector<edge>, greater<edge>> pq2;
  int ans = 0;
  pq1.push({c, r, startSX, startDX});
  pq2.push({c, r, startSX, startDX});
  while (pq1.size()) {
    auto t = pq1.top();
    pq1.pop();
    int x = t.x, y = t.y, sx = t.sx, dx = t.dx;
    if (visite1[y][x]) continue;
    visite1[y][x] = true;
    ++ans;
    for (int i = 0; i < 4; ++i) {
      int delx = moves[0][i], dely = moves[1][i];
      int remsx = (delx == -1);
      int remdx = (delx == 1);
      int cx = x + delx, cy = y + dely;
      if (cx < 0 || cy < 0 || sx - remsx < 0 || dx - remdx < 0 ||
          mat[cy][cx] == '*' || !mat[cy][cx] || visite1[cy][cx])
        continue;
      pq1.push({cx, cy, sx - remsx, dx - remdx});
    }
  }
  while (pq2.size()) {
    auto t = pq2.top();
    pq2.pop();
    int x = t.x, y = t.y, sx = t.sx, dx = t.dx;
    if (visite2[y][x]) continue;
    if (visite1[y][x] == false) ++ans;
    visite2[y][x] = true;
    for (int i = 0; i < 4; ++i) {
      int delx = moves[0][i], dely = moves[1][i];
      int remsx = (delx == -1);
      int remdx = (delx == 1);
      int cx = x + delx, cy = y + dely;
      if (cx < 0 || cy < 0 || sx - remsx < 0 || dx - remdx < 0 ||
          mat[cy][cx] == '*' || !mat[cy][cx] || visite2[cy][cx])
        continue;
      pq2.push({cx, cy, sx - remsx, dx - remdx});
    }
  }
  return ans;
}
int main() {
  int n, m;
  scanf("%d%d\n", &n, &m);
  int r, c;
  scanf("%d%d\n", &r, &c);
  int sinistra, destra;
  scanf("%d%d\n", &sinistra, &destra);
  for (int i = 0; i < n; ++i) {
    scanf("%s\n", mat[i]);
  }
  sinistra = min(sinistra, 4000000);
  destra = min(destra, 4000000);
  --r;
  --c;
  int ans = solve(r, c, sinistra, destra);
  printf("%d\n", ans);
}
