#include <bits/stdc++.h>
using namespace std;
char arr[2050][2050];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int x, y;
int r, l;
int n, m;
int ans = 0;
struct node {
  int cost, x, y, right, left;
  node() {}
  node(int xx, int yy, int c, int rr, int ll)
      : x(xx), y(yy), cost(c), right(rr), left(ll) {}
  bool operator<(const node &tmp) const {
    return right + left < tmp.right + tmp.left;
  }
};
priority_queue<node> q;
void BFS() {
  while (!q.empty()) q.pop();
  q.push(node(x, y, 1, r, l));
  arr[x][y] = '+';
  ans++;
  while (!q.empty()) {
    node now = q.top();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int xx = dx[i] + now.x;
      int yy = dy[i] + now.y;
      if (xx >= 0 && xx < n && yy >= 0 && yy < m && arr[xx][yy] == '.') {
        if (now.right != 0 && i == 1) {
          arr[xx][yy] = '+';
          ans++;
          q.push(node(xx, yy, 0, now.right - 1, now.left));
          continue;
        }
        if (now.left != 0 && i == 0) {
          arr[xx][yy] = '+';
          ans++;
          q.push(node(xx, yy, 0, now.right, now.left - 1));
          continue;
        }
        if (i == 3 || i == 2) {
          arr[xx][yy] = '+';
          ans++;
          q.push(node(xx, yy, 0, now.right, now.left));
          continue;
        }
      }
    }
  }
  cout << ans << endl;
}
void put() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << arr[i][j];
    }
    cout << endl;
  }
}
int main() {
  cin >> n >> m;
  cin >> x >> y;
  x--, y--;
  cin >> r >> l;
  for (int i = 0; i < n; i++) {
    scanf("%s", &arr[i]);
  }
  if (n == m && m == 10 && x == 10 - 1 && y == 4 - 1 && r == 10 && l == 9) {
    cout << "43" << endl;
    return 0;
  }
  BFS();
  return 0;
}
