#include <bits/stdc++.h>
using namespace std;
const int maxN = 4003;
char s[maxN][maxN];
bool flag[maxN][maxN];
struct Node {
  int r, c, x, y;
  Node() {}
  Node(int r, int c, int x, int y) : r(r), c(c), x(x), y(y) {}
} now;
queue<Node> que;
bool vis[maxN][maxN], used[maxN][maxN];
int main() {
  srand((unsigned)time(0));
  int n, m, r, c, x, y, ans = 0;
  scanf("%d%d%d%d%d%d", &n, &m, &r, &c, &x, &y);
  que.push(Node(r, c, x, y)), vis[r][c] = 1;
  for (r = 1; r <= n; ++r) {
    scanf("%s", s[r] + 1);
    for (c = 1; c <= m; ++c) flag[r][c] = (s[r][c] == '.');
  }
  while (!que.empty()) {
    now = que.front(), que.pop(), r = now.r, c = now.c, x = now.x, y = now.y;
    if (!used[r][c]) {
      for (; flag[r][c]; --r) {
      }
      for (++r; flag[r][c]; ++r) {
        vis[r][c] = used[r][c] = 1;
        if (rand() & 1) {
          if (flag[r][c - 1] && !vis[r][c - 1] && x)
            que.push(Node(r, c - 1, x - 1, y)), vis[r][c - 1] = 1;
          if (flag[r][c + 1] && !vis[r][c + 1] && y)
            que.push(Node(r, c + 1, x, y - 1)), vis[r][c + 1] = 1;
        } else {
          if (flag[r][c + 1] && !vis[r][c + 1] && y)
            que.push(Node(r, c + 1, x, y - 1)), vis[r][c + 1] = 1;
          if (flag[r][c - 1] && !vis[r][c - 1] && x)
            que.push(Node(r, c - 1, x - 1, y)), vis[r][c - 1] = 1;
        }
      }
    }
  }
  for (r = 1; r <= n; ++r)
    for (c = 1; c <= m; ++c)
      if (vis[r][c]) ++ans;
  printf("%d\n", ans);
  return 0;
}
