#include <bits/stdc++.h>
using namespace std;
string s[2005];
vector<int> adj[4000005];
int a[2001][2001];
int vis[4000005];
int n, m, r, c, x, y;
int find_ele(int xx, int yy, int m) {
  return 1 + xx + yy + (m - 1) * max(0, (xx));
}
int valid(int i, int j) {
  if (i < 0 || i >= n || j < 0 || j >= m) {
    return 0;
  }
  if (s[i][j] == '.') {
    return 1;
  }
  return 0;
}
int main() {
  cin >> n >> m;
  cin >> r >> c;
  r--;
  c--;
  cin >> x >> y;
  for (int j = 0; j < n; j++) {
    cin >> s[j];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = cnt;
      cnt++;
    }
  }
  deque<pair<pair<int, int>, pair<int, int>>> q;
  q.push_front({{r, c}, {0, 0}});
  cnt = 0;
  while (!q.empty()) {
    pair<pair<int, int>, pair<int, int>> p = q.front();
    q.pop_front();
    int xx = p.first.first;
    int yy = p.first.second;
    int wtl = p.second.first;
    int wtr = p.second.second;
    int ele = find_ele(xx, yy, m);
    if (vis[ele]) {
      continue;
    }
    s[xx][yy] = '+';
    cnt++;
    vis[ele] = 1;
    int ele2;
    if (valid(xx - 1, yy)) {
      ele2 = find_ele(xx - 1, yy, m);
      q.push_front({{xx - 1, yy}, {wtl, wtr}});
    }
    if (valid(xx + 1, yy)) {
      ele2 = find_ele(xx + 1, yy, m);
      q.push_front({{xx + 1, yy}, {wtl, wtr}});
    }
    if (valid(xx, yy + 1) && wtr + 1 <= y) {
      ele2 = find_ele(xx, yy + 1, m);
      q.push_back({{xx, yy + 1}, {wtl, wtr + 1}});
    }
    if (valid(xx, yy - 1) && wtl + 1 <= x) {
      ele2 = find_ele(xx, yy - 1, m);
      q.push_back({{xx, yy - 1}, {wtl + 1, wtr}});
    }
  }
  cout << cnt << endl;
}
