#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 10;
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
deque<pair<int, int> > qq;
int dis[maxn][maxn];
char s[maxn][maxn];
bool vis[maxn][maxn];
struct node {
  int dx, dy, left, right;
  node(int dx, int dy, int left, int right)
      : dx(dx), dy(dy), left(left), right(right){};
};
queue<node> q;
int n, m, r, c, x, y;
int solve1() {
  int ans = 1;
  memset(vis, 0, sizeof(vis));
  while (!q.empty()) {
    q.pop();
  }
  q.push(node(r - 1, c - 1, x, y));
  vis[r - 1][c - 1] = 1;
  while (!q.empty()) {
    node now = q.front();
    q.pop();
    for (int i = now.dx - 1; i >= 0; i--) {
      if (vis[i][now.dy] || s[i][now.dy] == '*') {
        break;
      }
      q.push(node(i, now.dy, now.left, now.right));
      vis[i][now.dy] = 1;
      ans++;
    }
    for (int i = now.dx + 1; i < n; i++) {
      if (vis[i][now.dy] || s[i][now.dy] == '*') {
        break;
      }
      q.push(node(i, now.dy, now.left, now.right));
      vis[i][now.dy] = 1;
      ans++;
    }
    if (now.dy > 0 && !vis[now.dx][now.dy - 1] &&
        s[now.dx][now.dy - 1] != '*' && now.left > 0) {
      q.push(node(now.dx, now.dy - 1, now.left - 1, now.right));
      vis[now.dx][now.dy - 1] = 1;
      ans++;
    }
    if (now.dy < m - 1 && !vis[now.dx][now.dy + 1] &&
        s[now.dx][now.dy + 1] != '*' && now.right > 0) {
      q.push(node(now.dx, now.dy + 1, now.left, now.right - 1));
      vis[now.dx][now.dy + 1] = 1;
      ans++;
    }
  }
  return ans;
}
int solve2() {
  --r;
  --c;
  int ans = 0;
  memset(dis, 0x20, sizeof(dis));
  dis[r][c] = 0;
  qq.push_back(make_pair(r, c));
  while (!qq.empty()) {
    int x = qq.front().first, y = qq.front().second;
    qq.pop_front();
    if (vis[x][y]) continue;
    vis[x][y] = 1;
    for (int k = 0; k < 4; k++) {
      int nx = x + dx[k], ny = y + dy[k];
      if (nx >= 0 && nx < n && ny >= 0 && ny < m && s[nx][ny] == '.') {
        if (k == 2) {
          if (dis[nx][ny] > dis[x][y] + 1) {
            dis[nx][ny] = dis[x][y] + 1;
            qq.push_back(make_pair(nx, ny));
          }
        } else {
          if (dis[nx][ny] > dis[x][y]) {
            dis[nx][ny] = dis[x][y];
            qq.push_front(make_pair(nx, ny));
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (dis[i][j] > n * m) continue;
      int l = dis[i][j], r = j - (c - l);
      if (l <= x && r <= y) ans++;
    }
  return ans;
}
int main() {
  while (~scanf("%d%d%d%d%d%d", &n, &m, &r, &c, &x, &y)) {
    memset(s, 0, sizeof(s));
    for (int i = 0; i < n; i++) {
      scanf("%s", s[i]);
    }
    int ans2 = solve2();
    cout << ans2 << endl;
  }
  return 0;
}
