#include <bits/stdc++.h>
using namespace std;
char mat[2010][2010];
bool visited[2010][2010];
int n, m, r, c, x, y, d[2010][2010];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
bool isValid(int x, int y) {
  if (x >= 1 && x <= n && y >= 1 && y <= m) return 1;
  return 0;
}
struct node {
  int x, y, l, r, w;
  node(int _x, int _y, int _l, int _r, int _w) {
    x = _x;
    y = _y;
    l = _l;
    r = _r;
    w = _w;
  }
  bool operator<(const node &cmp) const { return cmp.w < w; }
};
int ans;
void bfs() {
  priority_queue<node> pq;
  pq.push(node(r, c, x, y, 0));
  d[r][c] = 0;
  while (!pq.empty()) {
    node point = pq.top();
    pq.pop();
    int x = point.x, y = point.y;
    int l = point.l, r = point.r;
    int w = point.w;
    for (int i = 0; i < 4; i++) {
      int xx = dx[i] + x;
      int yy = dy[i] + y;
      if (isValid(xx, yy) && mat[xx][yy] == '.') {
        if (i == 2 || i == 3) {
          if (d[xx][yy] > d[x][y]) {
            d[xx][yy] = d[x][y];
            pq.push(node(xx, yy, l, r, d[xx][yy]));
          }
        } else if (i == 0) {
          if (d[xx][yy] > d[x][y] + 1) {
            if (r - 1 >= 0) {
              d[xx][yy] = d[x][y] + 1;
              pq.push(node(xx, yy, l, r - 1, d[xx][yy]));
            }
          }
        } else if (i == 1) {
          if (d[xx][yy] > d[x][y] + 1) {
            if (l - 1 >= 0) {
              d[xx][yy] = d[x][y] + 1;
              pq.push(node(xx, yy, l - 1, r, d[xx][yy]));
            }
          }
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  cin >> n >> m >> r >> c >> x >> y;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> mat[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      d[i][j] = 1e8;
    }
  }
  bfs();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (d[i][j] != 1e8 && mat[i][j] == '.') ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
