#include <bits/stdc++.h>
using namespace std;
const int N = 2000010, mod = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
struct ac {
  int x, y;
  pair<int, int> t;
  bool operator>(const ac& b) const { return t > b.t; }
};
int n, m, sx, sy, l, r;
char g[2010][2010];
void solve() {}
pair<int, int> d[2010][2010];
priority_queue<ac, vector<ac>, greater<ac>> q;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int main() {
  n = read(), m = read(), sx = read(), sy = read(), l = read(), r = read();
  for (int i = 1; i <= n; ++i) scanf("%s", g[i] + 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) d[i][j] = {1e9 + 10, 1e9 + 10};
  q.push({sx, sy, {0, 0}});
  d[sx][sy] = {0, 0};
  while (q.size()) {
    auto cur = q.top();
    q.pop();
    if (cur.t.first > l || cur.t.second > r) continue;
    for (int i = 0; i < 4; ++i) {
      int cx = cur.x + dx[i], cy = cur.y + dy[i];
      if (1 <= cx && cx <= n && 1 <= cy && cy <= m && g[cx][cy] != '*' &&
          make_pair(cur.t.first + (i == 2), cur.t.second + (i == 3)) <
              d[cx][cy]) {
        q.push({cx, cy, {cur.t.first + (i == 2), cur.t.second + (i == 3)}});
        d[cx][cy] = {cur.t.first + (i == 2), cur.t.second + (i == 3)};
      }
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (d[i][j].first <= l && d[i][j].second <= r) cnt++;
    }
  }
  cout << cnt;
  return 0;
}
