#include <bits/stdc++.h>
int n, m, l, ans;
char mp[2005][2005];
bool v2[2005][2005], vis[2005][2005];
int qx[2005 * 2005], qy[2005 * 2005], ux[2005 * 2005], uy[2005 * 2005], N;
void add(int x, int y, int nx, int ny, bool ty) {
  if (mp[x][y] == '*') return;
  if (vis[x][y]) return;
  ans++;
  if (!ty) {
    l--;
    if (l == 0) l = 2005 * 2005 - 1;
    qx[l] = x;
    qy[l] = y;
    ux[l] = nx;
    uy[l] = ny;
    vis[x][y] = 1;
    return;
  }
  qx[++N] = x;
  qy[N] = y;
  ux[N] = nx;
  uy[N] = ny;
  vis[x][y] = 1;
}
int main() {
  int rr, cc, xx, yy;
  scanf("%d%d%d%d%d%d", &n, &m, &rr, &cc, &xx, &yy);
  for (int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);
  for (int i = 1; i <= m; i++) mp[0][i] = mp[n + 1][i] = '*';
  for (int i = 1; i <= n; i++) mp[i][0] = mp[i][m + 1] = '*';
  add(rr, cc, xx, yy, 1);
  for (l = 1; l != N + 1;) {
    int x = qx[l], y = qy[l], nx = ux[l], ny = uy[l++];
    if (l == 2005 * 2005) l = 1;
    add(x - 1, y, nx, ny, 0);
    add(x + 1, y, nx, ny, 0);
    if (nx) add(x, y - 1, nx - 1, ny, 1);
    if (ny) add(x, y + 1, nx, ny - 1, 1);
  }
  printf("%d\n", ans);
}
