#include <bits/stdc++.h>
using namespace std;
int c[2001][2001], n, m, r, ccc, p, q, f[2001][2001];
int dx[12] = {1, -1, 0, 0}, dy[12] = {0, 0, -1, 1};
struct jk {
  int x, y, l, r;
};
int main() {
  cin >> n >> m >> r >> ccc >> p >> q;
  getchar();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char cc = getchar();
      if (cc == '.')
        c[i][j] = 0;
      else
        c[i][j] = 1;
    }
    getchar();
  }
  int s = 1;
  jk ds;
  ds.x = r;
  ds.y = ccc;
  ds.l = p;
  ds.r = q;
  deque<jk> q;
  q.push_front(ds);
  f[r][ccc] = 1;
  while (!q.empty()) {
    jk x = q.front();
    q.pop_front();
    for (int i = 0; i < 4; i++) {
      if (i == 2 && x.l == 0 || i == 3 && x.r == 0) continue;
      int xx = x.x + dx[i], yy = x.y + dy[i];
      if (xx > 0 && xx <= n && yy > 0 && yy <= m && c[xx][yy] == 0 &&
          f[xx][yy] == 0) {
        f[xx][yy] = 1;
        s++;
        if (i == 1 || i == 0) {
          jk t = x;
          t.x = xx;
          t.y = yy;
          q.push_front(t);
        } else if (i == 2) {
          jk t = x;
          t.x = xx;
          t.y = yy;
          t.l = x.l - 1;
          t.r = x.r;
          q.push_back(t);
        } else if (i == 3) {
          jk t = x;
          t.x = xx;
          t.y = yy;
          t.l = x.l;
          t.r = x.r - 1;
          q.push_back(t);
        }
      }
    }
  }
  cout << s << endl;
  return 0;
}
