#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
int n, m, R, L, y, x, cnt;
string f[N];
struct Pos {
  int y, x, l, r;
};
deque<Pos> q;
void chkPos(Pos p, bool left_right) {
  if (p.y < 0 || p.x < 0 || p.y >= n || p.x >= m) return;
  if (p.l <= L && p.r <= R && f[p.y][p.x] == '.') {
    f[p.y][p.x] = '+';
    cnt++;
    if (left_right)
      q.push_back(p);
    else
      q.push_front(p);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> y >> x >> L >> R;
  y--;
  x--;
  q.push_front({y, x, 0, 0});
  for (int i = 0; i < n; i++) cin >> f[i];
  f[y][x] = '+';
  cnt++;
  for (Pos p; !q.empty();) {
    p = q.front();
    q.pop_front();
    chkPos({p.y + 1, p.x, p.l, p.r}, false);
    chkPos({p.y - 1, p.x, p.l, p.r}, false);
    chkPos({p.y, p.x + 1, p.l, p.r + 1}, true);
    chkPos({p.y, p.x - 1, p.l + 1, p.r}, true);
  }
  cout << cnt;
}
