#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
bool flag[N][N], a[N][N];
int dis[N][N], n, m, r, c, sx, sy, ans;
char s[N];
struct node {
  int x, y, d;
  bool operator<(const node &B) const { return d > B.d; }
} q[N * N];
priority_queue<node> Q;
void bfs(int r, int c) {
  Q.push((node){r, c, 0});
  dis[r][c] = 0;
  while (!Q.empty()) {
    node u = Q.top();
    Q.pop();
    int x = u.x, y = u.y;
    if (flag[x][y]) continue;
    flag[x][y] = true;
    for (int i = 0; i < 4; i++) {
      int X = x + dx[i], Y = y + dy[i];
      if (X >= 1 && X <= n && Y >= 1 && Y <= m && a[X][Y] &&
          dis[X][Y] > dis[x][y] + (i < 2)) {
        Q.push((node){X, Y, dis[x][y] + (i < 2)});
        dis[X][Y] = dis[x][y] + (i < 2);
      }
    }
  }
}
int main() {
  memset(dis, 0x3f, sizeof(dis));
  scanf("%d%d%d%d%d%d", &n, &m, &r, &c, &sx, &sy);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j++) a[i][j] = (s[j] == '.');
  }
  bfs(r, c);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j]) {
        int x = (dis[i][j] + c - j) / 2;
        int y = (dis[i][j] - x);
        if (x <= sx && y <= sy) ans++;
      }
  printf("%d\n", ans);
  return 0;
}
