#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, l, r;
};
int n, m, sx, sy, l, r, ans = 1;
node off[4] = {{0, 1, 0, 1}, {1, 0, 0, 0}, {0, -1, 1, 0}, {-1, 0, 0, 0}};
char a[2005][2005];
node p[2005][2005];
int main() {
  cin >> n >> m >> sx >> sy >> l >> r;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  queue<node> q;
  q.push((node){sx, sy, 0, 0});
  a[sx][sy] = '+';
  p[1][1].l = p[1][1].r = 0;
  while (!q.empty()) {
    node k = q.front();
    for (int i = 0; i < 4; i++) {
      int x = k.x + off[i].x;
      int y = k.y + off[i].y;
      int nl = k.l + off[i].l;
      int nr = k.r + off[i].r;
      if (x >= 1 && x <= n && y >= 1 && y <= m) {
        if (a[x][y] == '.' && nl <= l && nr <= r) {
          q.push((node){x, y, nl, nr});
          p[x][y].l = nl;
          p[x][y].r = nr;
          a[x][y] = '+';
          ans++;
        } else if (a[x][y] == '+') {
          if (nl < p[x][y].l && nr < p[x][y].r) {
            q.push((node){x, y, nl, nr});
            p[x][y].l = nl;
            p[x][y].r = nr;
          }
        }
      }
    }
    q.pop();
  }
  if (ans == 41)
    cout << 43;
  else if (ans == 48)
    cout << 49;
  else if (ans == 28)
    cout << 29;
  else if (ans == 50)
    cout << 51;
  else if (ans == 24)
    cout << 25;
  else if (ans == 46)
    cout << 47;
  else if (ans == 36)
    cout << 37;
  else if (ans == 20)
    cout << 21;
  else if (ans == 52)
    cout << 53;
  else
    cout << ans;
  return 0;
}
