#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2050;
struct node {
  int x;
  int y;
  int l;
  int r;
};
int N, M, L, R, Ans = 0;
int disl[MAXN][MAXN], disr[MAXN][MAXN];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
char s[MAXN][MAXN], c;
bool vis[MAXN][MAXN];
node start;
queue<node> q;
bool check(int x, int y) { return 1 <= x && x <= N && 1 <= y && y <= M; }
void bfs(node start) {
  while (!q.empty()) q.pop();
  q.push(start);
  vis[start.x][start.y] = true;
  disl[start.x][start.y] = disr[start.x][start.y] = 0;
  Ans++;
  while (!q.empty()) {
    node qq = q.front();
    q.pop();
    for (int i = 0; i < 4; ++i) {
      int xx = qq.x + dx[i], yy = qq.y + dy[i], ll = qq.l + (dy[i] == -1),
          rr = qq.r + (dy[i] == 1);
      if (check(xx, yy) && ll <= L && rr <= R && s[xx][yy] != '*' &&
          (!vis[xx][yy] || (ll < disl[xx][yy] || rr < disr[xx][yy]))) {
        q.push(node{xx, yy, ll, rr});
        if (!vis[xx][yy]) Ans++;
        disl[xx][yy] = min(disl[xx][yy], ll);
        disr[xx][yy] = min(disr[xx][yy], rr);
        vis[xx][yy] = true;
      }
    }
  }
}
void Init() {
  memset(vis, false, sizeof(vis));
  scanf("%d%d%d%d%d%d", &N, &M, &start.x, &start.y, &L, &R);
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) {
      c = getchar();
      while (c != '.' && c != '*') c = getchar();
      s[i][j] = c;
    }
}
void Solve() {
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) disl[i][j] = disr[i][j] = 0x3f3f3f3f;
  start.l = start.r = 0;
  bfs(start);
}
void Print() { cout << Ans << endl; }
int main() {
  Init();
  Solve();
  Print();
  return 0;
}
