#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m, r, l, x, y;
  char cc;
  cin >> n >> m >> x >> y >> l >> r;
  vector<vector<int> > a(n + 2, vector<int>(m + 2));
  vector<vector<int> > used(n + 2, vector<int>(m + 2));
  vector<vector<pair<int, int> > > val(n + 2, vector<pair<int, int> >(m + 2));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> cc;
      if (cc == '.') a[i][j] = 1;
    }
  }
  deque<pair<int, int> > q;
  q.push_back({x, y});
  used[x][y] = 1;
  val[x][y] = {l, r};
  while (!q.empty()) {
    int i = q.front().first, j = q.front().second;
    q.pop_front();
    if (a[i + 1][j] && !used[i + 1][j]) {
      used[i + 1][j] = 1;
      val[i + 1][j] = val[i][j];
      q.push_front({i + 1, j});
    }
    if (a[i - 1][j] && !used[i - 1][j]) {
      used[i - 1][j] = 1;
      val[i - 1][j] = val[i][j];
      q.push_front({i - 1, j});
    }
    if (a[i][j + 1] && !used[i][j + 1] && val[i][j].second > 0) {
      used[i][j + 1] = 1;
      val[i][j + 1] = val[i][j];
      val[i][j + 1].second--;
      q.push_back({i, j + 1});
    }
    if (a[i][j - 1] && !used[i][j - 1] && val[i][j].first > 0) {
      used[i][j - 1] = 1;
      val[i][j - 1] = val[i][j];
      val[i][j - 1].first--;
      q.push_back({i, j - 1});
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (used[i][j]) cnt++;
    }
  }
  cout << cnt;
  return 0;
}
