#include <bits/stdc++.h>
const double eps = 1e-4, pi = acos(-1.0);
const int maxS = 2e3 + 13;
const int maxT = 20;
const long long MOD = 1e9 + 7;
using namespace std;
struct point {
  int x, y;
};
int n, m, i, j, k, x, y, z, S, T, ii, s, t, l, r, pos, len;
int tot = 0, ans = 0, res = 0, kase = 0, cnt;
bool chk[maxS][maxS], flag = true;
string s1, s2;
char ch[maxS][maxS];
int f[maxS][maxS], sx, sy;
queue<point> q;
void inq(int x, int y, int k) {
  if (k <= l && (y - sy + k) <= r && x > 0 && x <= n && y > 0 &&
      ch[x][y] == '.' && y <= m && k < f[x][y]) {
    f[x][y] = k;
    if (!chk[x][y]) {
      chk[x][y] = true;
      q.push({x, y});
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  memset(f, 0x3f3f3f3f, sizeof(f));
  cin >> n >> m >> sx >> sy >> l >> r;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> ch[i][j];
  q.push({sx, sy});
  f[sx][sy] = 0;
  while (!q.empty()) {
    x = q.front().x;
    y = q.front().y;
    chk[x][y] = false;
    q.pop();
    t = f[x][y];
    inq(x - 1, y, t);
    inq(x + 1, y, t);
    inq(x, y - 1, t + 1);
    inq(x, y + 1, t);
  }
  ans = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (f[i][j] < 0x3f3f3f3f) ans++;
  cout << ans << endl;
  return 0;
}
