#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int SUM = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    SUM = (SUM << 3) + (SUM << 1) + (ch ^ 48);
    ch = getchar();
  }
  return SUM * ff;
}
const int N = 2010;
const int inf = 0x3f3f3f3f;
struct node {
  int x, y;
  node(int _x = 0, int _y = 0) {
    x = _x;
    y = _y;
  }
};
const int xx[] = {-1, 1, 0, 0};
const int yy[] = {0, 0, 1, -1};
int g[N][N], dist[N][N];
bool inq[N][N];
int n, m, sx, sy, L, R;
int ans = 0;
inline char get() {
  char ch = getchar();
  while (ch != '.' && ch != '*') ch = getchar();
  return ch;
}
inline void BFS() {
  queue<node> q;
  memset(dist, inf, sizeof(dist));
  q.push(node(sx, sy));
  dist[sx][sy] = 0;
  inq[sx][sy] = 1;
  while (!q.empty()) {
    node now = q.front();
    q.pop();
    int x = now.x, y = now.y;
    inq[x][y] = 0;
    for (int i = 0; i < 4; i++) {
      int cx = x + xx[i], cy = y + yy[i];
      if (cx < 1 || cx > n || cy < 1 || cy > m || !g[cx][cy]) continue;
      if (dist[cx][cy] > dist[x][y] + (i == 3)) {
        dist[cx][cy] = dist[x][y] + (i == 3);
        if (!inq[cx][cy]) {
          q.push(node(cx, cy));
          inq[cx][cy] = 1;
        }
      }
    }
  }
}
int main() {
  n = read(), m = read(), sx = read(), sy = read(), L = read(), R = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) g[i][j] = (get() == '.');
  BFS();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (g[i][j] && dist[i][j] <= L && dist[i][j] + j - sy <= R) ans++;
  printf("%d\n", ans);
  return 0;
}
