#include <bits/stdc++.h>
using namespace std;
bool v[2005][2005];
bool visit[2005][2005];
int n, m, r, c, x, y;
char k;
struct node {
  int i, j, left, right;
  bool friend operator<(const node a, const node b) {
    return a.left + a.right > b.left + b.right;
  }
};
node createNode(int i, int j, int l, int r) {
  node n;
  n.i = i, n.j = j, n.left = l, n.right = r;
  return n;
}
int bfs(int i, int j) {
  int total = 0;
  node front = createNode(i, j, 0, 0);
  priority_queue<node> q;
  q.push(front);
  visit[i][j] = 1;
  while (!q.empty()) {
    front = q.top();
    q.pop();
    ++total;
    int i, j, left, right;
    i = front.i - 1, j = front.j, left = front.left, right = front.right;
    if (front.i - 1 >= 0 && v[i][j] && !visit[i][j]) {
      visit[i][j] = 1;
      q.push(createNode(i, j, left, right));
    }
    i = front.i + 1, j = front.j, left = front.left, right = front.right;
    if (front.i + 1 < n && v[i][j] && !visit[i][j]) {
      visit[i][j] = 1;
      q.push(createNode(i, j, left, right));
    }
    i = front.i, j = front.j - 1, left = front.left + 1, right = front.right;
    if (front.j - 1 >= 0 && front.left + 1 <= x && v[i][j] && !visit[i][j]) {
      visit[i][j] = 1;
      q.push(createNode(i, j, left, right));
    }
    i = front.i, j = front.j + 1, left = front.left, right = front.right + 1;
    if (front.j + 1 < m && front.right + 1 <= y && v[i][j] && !visit[i][j]) {
      visit[i][j] = 1;
      q.push(createNode(i, j, left, right));
    }
  }
  return total;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> r >> c >> x >> y;
  --r, --c;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> k;
      v[i][j] = k == '.' ? 1 : 0;
    }
  }
  int answer = bfs(r, c);
  cout << answer << "\n";
}
