#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long dx[] = {1, -1, 0, 0};
long long dy[] = {0, 0, 1, -1};
string s[2005];
long long dist[2005][2005];
struct node {
  long long x, y, w;
  node(long long _x, long long _y) {
    x = _x;
    y = _y;
    w = 1LL << 40;
  }
  node(long long _x, long long _y, long long _w) {
    x = _x;
    y = _y;
    w = _w;
  }
};
struct cmp {
  bool operator()(node const& p1, node const& p2) { return p1.w > p2.w; }
};
bool valid(long long x, long long y, long long n, long long m) {
  if (min(x, y) < 0) return false;
  if (x >= m) return false;
  if (y >= n) return false;
  return s[y][x] == '.';
}
void solve() {
  long long i, j, k, l, r, m, n, a, b, c, d, x, y, z, t;
  cin >> n >> m >> y >> x >> a >> b;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) dist[j][i] = (1LL << 40);
  for (i = 0; i < n; i++) cin >> s[i];
  x--;
  y--;
  c = x;
  d = y;
  priority_queue<node, vector<node>, cmp> sh;
  sh.push(node(x, y, 0));
  dist[x][y] = 0;
  while (!sh.empty()) {
    node temp = sh.top();
    sh.pop();
    x = temp.x;
    y = temp.y;
    for (i = 0; i < 4; i++) {
      long long cur = 0;
      if (dx[i] != 0) cur++;
      if (valid(x + dx[i], y + dy[i], n, m)) {
        if (temp.w < dist[x + dx[i]][y + dy[i]]) {
          dist[x + dx[i]][y + dy[i]] = temp.w + cur;
          sh.push(node(x + dx[i], y + dy[i], temp.w + cur));
        }
      }
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      long long dis = abs(j - c);
      long long lft, rht;
      lft = rht = (dist[j][i] - dis) / 2;
      if (j > c)
        rht += dis;
      else
        lft += dis;
      if (lft <= a && rht <= b) ans++;
    }
  }
  cout << ans << endl;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
