#include <bits/stdc++.h>
using namespace std;
int mult(int a, int b, int p = 1000000007) { return ((a % p) * (b % p)) % p; }
int add(int a, int b, int p = 1000000007) { return (a % p + b % p) % p; }
int fpow(int n, int k, int p = 1000000007) {
  int r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
int inv(int a, int p = 1000000007) { return fpow(a, p - 2, p); }
int inv_euclid(int a, int m = 1000000007) {
  int m0 = m;
  int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    int q = a / m;
    int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
string s[2003];
int rr, cc;
int n, m;
int x, y;
int issafe(int r, int c, int x, int y) {
  if (r >= 0 && r < n && c >= 0 && c < m && s[r][c] == '.' && x >= 0 &&
      y >= 0) {
    return 1;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  cin >> rr >> cc;
  cin >> x >> y;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  rr--;
  cc--;
  priority_queue<pair<int, pair<pair<int, int>, pair<int, int> > >,
                 vector<pair<int, pair<pair<int, int>, pair<int, int> > > >,
                 greater<pair<int, pair<pair<int, int>, pair<int, int> > > > >
      q;
  q.push(make_pair(0, make_pair(make_pair(rr, cc), make_pair(x, y))));
  s[rr][cc] = '+';
  while (!q.empty()) {
    pair<int, pair<pair<int, int>, pair<int, int> > > p = q.top();
    q.pop();
    int r = p.second.first.first;
    int c = p.second.first.second;
    int xx = p.second.second.first;
    int yy = p.second.second.second;
    int cnt = p.first;
    if (issafe(r - 1, c, xx, yy)) {
      q.push(make_pair(cnt, make_pair(make_pair(r - 1, c), make_pair(xx, yy))));
      s[r - 1][c] = '+';
    }
    if (issafe(r + 1, c, xx, yy)) {
      q.push(make_pair(cnt, make_pair(make_pair(r + 1, c), make_pair(xx, yy))));
      s[r + 1][c] = '+';
    }
    if (issafe(r, c - 1, xx - 1, yy)) {
      q.push(make_pair(cnt + 1,
                       make_pair(make_pair(r, c - 1), make_pair(xx - 1, yy))));
      s[r][c - 1] = '+';
    }
    if (issafe(r, c + 1, xx, yy - 1)) {
      q.push(make_pair(cnt + 1,
                       make_pair(make_pair(r, c + 1), make_pair(xx, yy - 1))));
      s[r][c + 1] = '+';
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '+') {
        ans++;
      }
    }
  }
  cout << ans << "\n";
}
