#include <bits/stdc++.h>
using namespace std;
struct Cell {
  int x;
  int y;
  int left;
  int right;
};
struct Val {
  int left;
  int right;
};
char grid[2001][2001];
Val vis[2001][2001];
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  int r, c;
  scanf("%d", &r);
  scanf("%d", &c);
  int x, y;
  scanf("%d", &x);
  scanf("%d", &y);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf(" %c", &grid[i][j]);
    }
  }
  queue<Cell> pq;
  pq.push({r - 1, c - 1, 0, 0});
  bool visited[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      visited[i][j] = false;
      vis[i][j] = {-1, -1};
    }
  }
  int count = 0;
  while (!pq.empty()) {
    Cell curr = pq.front();
    pq.pop();
    int i = curr.x;
    int j = curr.y;
    int l = curr.left;
    int r = curr.right;
    if (!visited[i][j] || (vis[i][j].left > l && vis[i][j].right > r)) {
      visited[i][j] = true;
      vis[i][j] = {l, r};
      if (i + 1 < n && grid[i + 1][j] == '.') {
        if (!visited[i + 1][j])
          pq.push({i + 1, j, l, r});
        else if (vis[i + 1][j].left > l && vis[i + 1][j].right > r) {
          visited[i + 1][j] = false;
          pq.push({i + 1, j, l, r});
        }
      }
      if (i - 1 >= 0 && grid[i - 1][j] == '.') {
        if (!visited[i - 1][j])
          pq.push({i - 1, j, l, r});
        else if (vis[i - 1][j].left > l && vis[i - 1][j].right > r) {
          visited[i - 1][j] = false;
          pq.push({i - 1, j, l, r});
        }
      }
      if (j + 1 < m && grid[i][j + 1] == '.') {
        if (y - r > 0) {
          if (!visited[i][j + 1])
            pq.push({i, j + 1, l, r + 1});
          else if (vis[i][j + 1].left > l && vis[i][j + 1].right > r + 1) {
            visited[i][j + 1] = false;
            pq.push({i, j + 1, l, r + 1});
          }
        }
      }
      if (j - 1 >= 0 && grid[i][j - 1] == '.') {
        if (x - l > 0) {
          if (!visited[i][j - 1])
            pq.push({i, j - 1, l + 1, r});
          else if (vis[i][j - 1].left > l + 1 && vis[i][j - 1].right > r) {
            visited[i][j - 1] = false;
            pq.push({i, j - 1, l + 1, r});
          }
        }
      }
    }
  }
  count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (visited[i][j] && vis[i][j].left <= x && vis[i][j].right <= y) {
        count++;
      }
    }
  }
  printf("%d", count);
}
